Error codes

E0401: unreachable clause or arm

In a terminal: auk explain E0401 prints this page.

On this page

Arms and clauses are tried top to bottom, and the earlier ones already match every value this one could, so it can never run. That usually means the order is wrong; the fix removes it.

Wrong#

auk
fn sign(n: int): str = match n {
  _ => "other"
  0 => "zero"
}

Fixed#

auk
fn sign(n: int): str = match n {
  0 => "zero"
  _ => "other"
}

Common causes#

  • A catch-all _ or bare name placed before more specific patterns.
  • A duplicated arm after a copy-paste.
  • A clause fn f(n: int) placed above fn f(0).

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