E1039#
Method name conflicts with another definition.
Note
Methods declared with the syntax fn f(self : T, ..)
will be promoted to
regular function in the future, declare the method using fn T::f(..)
to avoid
name clash.
Erroneous example#
type A Int
fn f() -> Int {
3
}
fn f(self : A) -> Int {
self._
}
fn main {
println(f())
println(A(3).f())
}
Suggestion#
You can defined the method as A::f
:
fn T::f(self : A) -> Int {
self._
}
However, defining a method with T::
prefix makes it impossible to be invoked
as regular function. If you wish to call the method as regular function, then
you have to rename either the method name, or the regular function name to
resolve the name clash.
fn f_(self : A) -> Int {
self._
}
fn main {
println(f_(A(3)))
}