bynk.types.unknown_variant_in_pattern
Error A pattern names a variant the sum type does not have.
A pattern on a sum value can only name the variants its type declares, so Square(side) against a Shape with no Square could never match and is refused. This is usually a typo, a variant that was never added, or a value of a different type from the one intended. Fix the name, add the variant to the type, or match on the right value. A pattern of the wrong kind altogether is bynk.types.pattern_type_mismatch.
Example
type Shape = | Circle(radius: Int) | Dot
fn size(s: Shape) -> Int { match s { Circle(r) => r Square(side) => side // ✗ `Shape` has no `Square` 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.unknown_variant_in_patternshows the same from the installed toolchain, without a network.