Skip to content
Playground(another site)

bynk.types.unreachable_arm

Error A match arm is unreachable.

A match arm can never run, because the arms before it already match every value it would match. The usual cause is a wildcard _ placed before more specific arms: arms are tried in order, so the wildcard takes everything and the rest are dead code, which Bynk refuses rather than let hide a mistake. Put the specific arms first and the wildcard last, or delete the arm. A guarded arm covers nothing, since its guard may fail.

Example

type Status = enum { Pending, Active, Done }
fn label(s: Status) -> String {
match s {
_ => "other"
Pending => "waiting" // ✗ the `_` above already matches it
}
}
fn label(s: Status) -> String {
match s {
Pending => "waiting"
_ => "other" // ✓ the catch-all last
}
}

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