Error codes

E0021: expected an expression

In a terminal: auk explain E0021 prints this page.

On this page

A value was expected here (after an operator, =, ( or ,) but the next token can't start one. Auk closures are written x => ..., never fn (x) ....

Wrong#

auk
fn double(xs: [int]): [int] = xs.map(fn(x) x * 2)

Fixed#

auk
fn double(xs: [int]): [int] = xs.map(x => x * 2)

Common causes#

  • A closure written with fn, |x| or lambda: write x => ... or (a, b) => ....
  • A dangling operator: a + * b, or a trailing + with nothing after it.
  • _ used as a value; it only works in patterns.
  • assert used inside an expression; it is a statement.

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