bynk.types.or_pattern_binding_mismatch
Error An or-pattern's alternatives don't all bind the same set of names.
An or-pattern, Walk(steps) | Wait, runs one arm for either alternative, so every alternative must bind the same names. If steps came only from Walk, the arm's body would read a name that does not exist when Wait matched. Bind the name in every alternative, bind it in none with _, or split the alternatives into separate arms. A shared name must also have the same type: see bynk.types.or_pattern_type_mismatch.
Example
type Move = | Walk(steps: Int) | Wait
fn cost(m: Move) -> Int { match m { Walk(steps) | Wait => 1 // ✗ `steps` is bound by one alternative only }}
fn cost(m: Move) -> Int { match m { Walk(_) | Wait => 1 // ✓ neither alternative binds }}In the Book
See also
- The grammar rules it governs:
match_arm,is_expr. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.or_pattern_binding_mismatchshows the same from the installed toolchain, without a network.