bynk.types.match_non_sum_discriminant
Error match was applied to a value that is not a sum type.
match chooses between alternatives, so it needs a value that has some: a sum, an enum, a Result or Option, an Int, String or Bool, or a list matched by list patterns. A Float or a function has none, and a record has a single shape, so it can be matched only with a record pattern such as Point { x, .. }. Read a field directly, and use if to branch on a condition.
Example
type Point = { x: Int, y: Int }
fn first(p: Point) -> Int { match p { // ✗ a record has one shape, not variants _ => 1 }}
fn first(p: Point) -> Int { p.x // ✓ read the field}In the Book
See also
- The grammar rule it governs:
match_expr. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.match_non_sum_discriminantshows the same from the installed toolchain, without a network.