Error codes

E0403: pattern that might not match where one must always match

In a terminal: auk explain E0403 prints this page.

On this page

A plain let, a for loop and function parameters bind with patterns that must match every value. This one might not; the message shows a value it misses. Auk never fails a binding silently at run time.

Wrong#

auk
fn head(xs: [int]): int {
  let [h, ..t] = xs
  h
}

Fixed#

auk
fn head(xs: [int]): int {
  let [h, ..t] = xs else { return 0 }
  h
}

Common causes#

  • Destructuring a list, enum or literal with a plain let: add else { ... }, or use match.
  • for Circle(r) in shapes: filter first, or match inside the loop.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page