A var parameter changes the caller's variable, and Auk makes that visible at the call site
with &, so a reader can see which arguments a call may modify.
Wrong#
fn bump(n: var int) { n += 1 }
fn main() {
var x = 1
bump(x)
print(x)
}Fixed#
fn bump(n: var int) { n += 1 }
fn main() {
var x = 1
bump(&x)
print(x)
}Common causes#
- Forgetting the
&on a call to a mutating function. - A dot call needs no
&:x.bump()works as well.