Skip to content
Playground(another site)

bynk.types.variant_payload_mismatch

Error A variant payload has the wrong type.

A variant's payload fields have declared types and are checked like function parameters: Circle("big") for radius: Int is refused at the argument, with no conversion. Pass a value of the field's type. For a generic sum the type argument is inferred from the arguments first, and the check applies to the result. The wrong number of arguments is bynk.types.variant_arity.

Example

type Shape =
| Circle(radius: Int)
| Dot
fn make() -> Shape {
Circle("big") // ✗ `radius` is an `Int`
}
fn make() -> Shape {
Circle(10) // ✓
}

In the Book

See also

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