Error codes

E0265: name bound twice in a pattern

In a terminal: auk explain E0265 prints this page.

On this page

Each name in a pattern binds a new variable, so one name can't appear twice. Auk patterns don't test equality by repeating a name: use a when guard for that.

Wrong#

auk
fn same(p: (int, int)): bool = match p {
  (a, a) => true
  _ => false
}

Fixed#

auk
fn same(p: (int, int)): bool = match p {
  (a, b) when a == b => true
  _ => false
}

Common causes#

  • Expecting a repeated name to mean "these are equal" (as in Prolog or Erlang).
  • A copy-paste typo in a tuple or list pattern.

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