E0066

E0066#

Warning name: prefer_fixed_array

Suggest FixedArray for mutated array literal.

This warning is emitted when an array literal is created and then mutated. Consider using FixedArray to better express intent.

Erroneous example#

test {
  let xs = [1, 2, 3]
  xs[0] = 4
  inspect(xs[0], content="4")
}

Suggestion#

Annotate the array literal as FixedArray:

test {
  let xs : FixedArray[Int] = [1, 2, 3]
  xs[0] = 4
  inspect(xs[0], content="4")
}