docs

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

#E0051: invalid spread argument

f(..x) spreads a tuple, List, Slice, array or Dict<str, V> into the arguments, and needs a callee known at compile time. Spread one of those, or pass the arguments one by one.

nabi
fn sum(xs: ...i32) -> i32 { 0 }

let n = 3;
println(f"{sum(..n)}");
error[E0051]: spread into a variadic `...T` needs a tuple, a `List`, a `Slice` or an array, found `i64`
  --> main.nabi:4:12
   |
 4 | println(f"{sum(..n)}");
   |            ^^^^^^^^

Spread a collection:

nabi
fn sum(xs: ...i32) -> i32 {
    let t = 0;
    for x in xs { t += x; }
    t
}

let ns = [1, 2, 3];
println(f"{sum(..ns)}");
6

Related: E0048 wrong number of arguments

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