Error codes

E0223: bad tuple index

In a terminal: auk explain E0223 prints this page.

On this page

t.0, t.1, ... access a tuple's elements, numbered from 0. The index is past the end of the tuple, or the value isn't a tuple at all.

Wrong#

auk
fn second(p: (int, str)): str = p.2

Fixed#

auk
fn second(p: (int, str)): str = p.1

Common causes#

  • Counting tuple elements from 1 instead of 0.
  • A numeric field on a struct or list: use xs[0] for lists and named fields for structs.
  • Destructuring is often clearer: let (n, s) = p.

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