Error codes

E0022: expected a pattern

In a terminal: auk explain E0022 prints this page.

On this page

A pattern was expected (a match arm, a clause parameter, the left side of let) but this token can't start one. Patterns look like 0, "s", x, _, (a, b), [h, ..t], Circle(r), User { name, .. } or "GET " + rest.

Wrong#

auk
fn sign(n: int): int = match n {
  => 0
}

Fixed#

auk
fn sign(n: int): int = match n {
  0 => 0
  _ => 1
}

Common causes#

  • A match arm with the pattern left out.
  • An expression where a pattern belongs: n + 1 => ...; use a guard x when x > 0 => ....
  • A string-prefix pattern with a literal after +: "a" + "b"; bind a name instead.

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