E3011

E3011#

The assignment contains an invalid left-hand-side (LHS) expression, such as a constant or a constructor.

Erroneous example#

const N = 4

fn assign_const() -> Int {
  N = 5 // Error: Invalid left value for assignment.
  N
}

test {
  inspect(assign_const(), content="5")
}

Suggestion#

Change the LHS to a valid mutable memory location, such as a mutable variable or a mutable field:

///|
fn assign_mutable() -> Int {
  let mut n = 4
  n = 5
  n
}

///|
test {
  inspect(assign_mutable(), content="5")
}