Skip to content
Playground(another site)

bynk.resolve.duplicate_method

Error Two methods share a name.

A method is looked up by its type and name, so p.norm() has to mean one body. A second fn Point.norm would leave the call with nothing to choose between. Delete the repeat, or give it a different name if it does something else.

Example

type Point = { x: Int }
fn Point.norm(self) -> Int { self.x }
fn Point.norm(self) -> Int { 0 } // ✗ `Point.norm` is already declared
fn Point.isOrigin(self) -> Bool { self.x == 0 } // ✓ a different name

In the Book

See also

  • The grammar rule it governs: fn_decl.
  • Every code in its category, Resolution, on the diagnostic index.
  • bynk explain bynk.resolve.duplicate_method shows the same from the installed toolchain, without a network.