Error codes

E0034: invalid map pattern

In a terminal: auk explain E0034 prints this page.

On this page

Map patterns match fixed keys, so each key must be a literal like {"name": n}. A variable key can't be used to look up an entry in a pattern.

Wrong#

auk
fn name(m: {str: str}): str = match m {
  {k: v} => v
  _ => ""
}

Fixed#

auk
fn name(m: {str: str}): str = match m {
  {"name": v} => v
  _ => ""
}

Common causes#

  • Trying to iterate a map with a pattern: use for k, v in m { ... }.
  • A key read from a variable: use m.get(k) instead.

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