Error codes

E0262: pattern doesn't match the value's type

In a terminal: auk explain E0262 prints this page.

On this page

The pattern could never match because it describes a different type than the value being matched, such as a string pattern against an int.

Wrong#

auk
fn f(x: int): int = match x {
  "a" => 1
  _ => 2
}

Fixed#

auk
fn f(x: int): int = match x {
  1 => 1
  _ => 2
}

Common causes#

  • Matching on the wrong variable.
  • A pattern for a different enum, or a variant from another type.
  • A map pattern whose key type differs from the map's key type.

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