Skip to content
Playground(another site)

bynk.contract.duplicate_name

Error A function declares two contract clauses (requires/ensures) with the same name.

Every requires and ensures clause has a name, and a failure report points at a clause by that name, so each name must be unique within one function, across both kinds. Rename the repeat; the error is on its name.

Example

fn inc(x: Int) -> Int
requires bigger: x > 0
ensures bigger: result > x // ✗ `bigger` is already taken
fn inc(x: Int) -> Int
requires positive: x > 0
ensures bigger: result > x // ✓

In the Book

See also

  • Every code in its category, Contracts, on the diagnostic index.
  • bynk explain bynk.contract.duplicate_name shows the same from the installed toolchain, without a network.