&x marks an argument the callee may change, which only var parameters can do. This
parameter isn't var, so the & is misleading and rejected.
Wrong#
fn show(xs: [int]) { print(xs) }
fn main() {
var a = [1]
show(&a)
}Fixed#
fn show(xs: [int]) { print(xs) }
fn main() {
var a = [1]
show(a)
}Common causes#
- Using
&to "pass by reference" for speed: Auk copies cheaply (copy-on-write). - The callee was meant to change it: declare the parameter
xs: var [int].