Error codes

E0270: not indexable

In a terminal: auk explain E0270 prints this page.

On this page

x[i] and slices x[a..b] work on lists, strings and maps (m[k]). This value is none of those.

Wrong#

auk
fn digit(n: int): int = n[0]

Fixed#

auk
fn digit(n: int): int = int(str(n)[0]) - int('0')

Common causes#

  • Indexing a number: convert it with str(n) first.
  • Indexing a tuple: use t.0, t.1.
  • Indexing a struct: use its field names.
  • Indexing a T?: unwrap it first.

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