Skip to content
Playground(another site)

bynk.types.unknown_pattern_field

Error A pattern names a field the variant does not have.

When a variant pattern names its bindings, as in Circle(radius: r), each name must be a payload field the variant declares: Circle has no diameter. Use the declared field name, or bind by position, Circle(r). A count of bindings that does not fit the payload is bynk.types.pattern_arity.

Example

type Shape =
| Circle(radius: Int)
| Dot
fn size(s: Shape) -> Int {
match s {
Circle(diameter: d) => d // ✗ `Circle` has no field `diameter`
Dot => 0
}
}
fn size(s: Shape) -> Int {
match s {
Circle(radius: 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.unknown_pattern_field shows the same from the installed toolchain, without a network.