E0065#
Warning name: prefer_readonly_array
Suggest ReadOnlyArray for read-only array literal.
This warning is emitted when the compiler can infer that an array literal is
used in a read-only way. Consider using ReadOnlyArray to better express
intent.
Erroneous example#
test {
let xs = [1, 2, 3]
inspect(xs[0], content="1")
}
Suggestion#
Annotate the array literal as ReadOnlyArray:
test {
let xs : ReadOnlyArray[Int] = [1, 2, 3]
inspect(xs[0], content="1")
}