Error codes

E0027: invalid assignment target

In a terminal: auk explain E0027 prints this page.

On this page

Only a variable, a field or an index can be assigned (x = 1, p.x = 1, xs[i].y = 1), or with a plain = a tuple of them ((a, b) = (b, a)). The left side here is some other expression, like a call or an arithmetic result.

Wrong#

auk
fn main() {
  var a = 1
  a + 1 = 3
  print(a)
}

Fixed#

auk
fn main() {
  var a = 1
  a = 3 - 1
  print(a)
}

Common causes#

  • = used as a comparison in an expression: use ==.
  • Assigning to a call result: get(m) = v; use m[k] = v or a setter function.
  • An equation solved the wrong way round.
  • A compound assignment to a tuple ((a, b) += (1, 1)): assign each one.

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