Error codes

E0310: missing & for a var parameter

In a terminal: auk explain E0310 prints this page.

On this page

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#

auk
fn bump(n: var int) { n += 1 }
fn main() {
  var x = 1
  bump(x)
  print(x)
}

Fixed#

auk
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.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page