Skip to content
Playground(another site)

bynk.types.non_exhaustive_match

Error A match does not cover every value.

A match must cover every value its subject can take, so it can never fall off its end. The compiler names a case that no arm covers: add an arm for it, or end the match with a wildcard _ arm. Listing every variant a type has today is not a substitute for _ where the compiler says one is needed, and where a match is too complex for it to prove exhaustive it asks for _ too.

Example

type Status = enum { Pending, Active, Done }
match s { // ✗ `Done` is not covered
Pending => "p"
Active => "a"
}
match s {
Pending => "p"
Active => "a"
Done => "d" // ✓ every variant covered
}

In the Book

See also

  • The grammar rule it governs: match_expr.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.non_exhaustive_match shows the same from the installed toolchain, without a network.