Skip to content
Playground(another site)

bynk.types.constructor_arity

Error T.of (or T.unsafe) on a refined or opaque type got the wrong number of arguments.

T.of(value) takes exactly one argument, the base value to check, and so does T.unsafe(value) on an opaque type: a refined or opaque type wraps a single value. None gives it nothing to check, and two have no meaning. Pass the one value. Building a sum variant with the wrong number of arguments is bynk.types.variant_arity.

Example

type Age = Int where InRange(0, 150)
fn parse(n: Int) -> Result[Age, ValidationError] {
Age.of(n, 1) // ✗ `of` takes 1 argument
}
fn parse(n: Int) -> Result[Age, ValidationError] {
Age.of(n) // ✓
}

In the Book

See also

  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.constructor_arity shows the same from the installed toolchain, without a network.