bynk.types.pattern_arity
Error A pattern binds the wrong number of payload fields.
A variant pattern takes one binding for each payload field the variant declares, in order, or none to ignore the payload. A different count, or any binding on a variant with no payload, is refused: an extra name has nothing to hold, and a missing one would silently drop a field. Use _ for a field you do not need, or name the fields you want (radius: r). Building a variant with the wrong number of arguments is bynk.types.variant_arity.
Example
type Shape = | Circle(radius: Int) | Dot
fn size(s: Shape) -> Int { match s { Circle(r, extra) => r // ✗ `Circle` has one field Dot => 0 }}
fn size(s: Shape) -> Int { match s { Circle(r) => r // ✓ Dot => 0 }}In the Book
See also
- The grammar rule it governs:
variant_pattern. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.pattern_arityshows the same from the installed toolchain, without a network.