E1040

E1040#

This method is declared as T::f, Calling this kind of method directly via name(..) is deprecated, use qualified syntax T::f(..), or declare the method as fn f(self : A, ..) instead.

Erroneous example#

type A Int

fn A::f(self : A) -> Int {
  self._
}

fn main {
  let _ = f(A(1))
  // Warning:
  // This method is declared as A::f, calling this kind of method directly via
  // f(..) is deprecated, use qualified syntax A::f(..), or declare the method
  // as `fn f(self : A, ..)` instead.
}

Suggestion#

You can either modify the calling of this function at call sites:

fn main {
  let _ = A::f(A(1))
}

Or you can define the method as:

fn f(self : A) -> Int {
  self._
}

fn main {
  let _ = f(A(1))
}