docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

#E0050: ref parameter and argument mismatch

A ref parameter takes an argument written ref x, which names a variable or a field of one; a plain parameter takes a plain argument. The same variable cannot go to two ref parameters of one call. Write ref exactly where the parameter has it.

nabi
fn inc(ref n: i32) { n += 1; }

let c = 0;
inc(c);
error[E0050]: parameter `n` of `inc` is `ref` - pass `ref c` at the call site
  --> main.nabi:4:1
   |
 4 | inc(c);
   | ^^^^^^

Write ref at the call too:

nabi
fn inc(ref n: i32) { n += 1; }

let c = 0;
inc(ref c);
println(f"{c}");
1

Related: E0048 wrong number of arguments, E0057 invalid assignment

Found a mistake? Edit this page on GitHub. Last updated