bynk.types.duplicate_literal_arm
Error A match has two arms for the same literal value.
A match takes the first arm whose pattern fits, so a literal that an earlier unguarded arm already has can never reach a second arm. Bynk refuses the dead arm rather than let it hide a mistake, usually a mistyped value. Change the literal or delete the arm. An or-pattern is checked alternative by alternative, so 1 | 2 followed by 2 is caught as well. The same for a variant is bynk.types.duplicate_variant_arm.
Example
fn word(n: Int) -> String { match n { 1 => "one" 1 => "uno" // ✗ `1` is already matched above _ => "other" }}
fn word(n: Int) -> String { match n { 1 => "one" 2 => "two" // ✓ _ => "other" }}In the Book
See also
- The grammar rule it governs:
match_arm. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.duplicate_literal_armshows the same from the installed toolchain, without a network.