Error codes

E0033: invalid list pattern

In a terminal: auk explain E0033 prints this page.

On this page

A list pattern can have at most one .. (the rest of the list). With two, it is unclear how many items each one takes.

Wrong#

auk
fn ends(xs: [int]): int = match xs {
  [a, .., b, ..] => a + b
  _ => 0
}

Fixed#

auk
fn ends(xs: [int]): int = match xs {
  [a, .., b] => a + b
  _ => 0
}

Common causes#

  • Trying to match an element in the middle of a list: use find or a loop.
  • A leftover .. after an edit.

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