Skip to content
Playground(another site)

bynk.types.duplicate_variant_arm

Error A match has two arms for the same variant.

A match runs the first arm that fits, so a second unguarded arm for a variant that an earlier arm already covers can never run. Bynk refuses the dead arm rather than let it hide a slip, usually a copied arm whose pattern was never changed. Delete it, or change it to the variant you meant. Arms are compared by shape, so Err(A) and Err(B) are not duplicates. The same mistake with a literal is bynk.types.duplicate_literal_arm.

Example

type Light = | Red | Green
fn go(l: Light) -> Int {
match l {
Red => 1
Red => 2 // ✗ `Red` is already matched above
Green => 3
}
}
fn go(l: Light) -> Int {
match l {
Red => 1
Green => 2 // ✓ each variant once
}
}

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_variant_arm shows the same from the installed toolchain, without a network.