bynk.types.pattern_type_mismatch
Error A pattern's type does not match the matched value.
A pattern can only match values of the type it describes, so a pattern of another kind than the value being matched can never succeed and is refused. A literal pattern must have the scrutinee's type, so "one" cannot match an Int. A variant pattern needs a sum value, a record pattern needs that record, and a qualified pattern such as Status.Active must name the scrutinee's own type. Match on the type the value has, or convert the value before the match. A pattern with the wrong number of bindings is bynk.types.pattern_arity.
Example
fn word(n: Int) -> String { match n { "one" => "uno" // ✗ a `String` pattern, an `Int` scrutinee _ => "other" }}
fn word(n: Int) -> String { match n { 1 => "uno" // ✓ _ => "other" }}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_type_mismatchshows the same from the installed toolchain, without a network.