docs

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

#E0042: type annotations needed

The compiler cannot work out a type from the code: an empty literal, a closure parameter nothing constrains, or a generic call whose type arguments nothing fixes. Write the type: let v: List<i32> = [];, |x: i32| .., or f::<i32>(..).

nabi
let xs = [];
error[E0042]: type annotations needed: cannot infer the type of `xs` (`List<_>`) from its initializer or later uses - add an annotation naming its arguments (`let xs: List<..> = ..`)
  --> main.nabi:1:1
   |
 1 | let xs = [];
   | ^^^

Write the type:

nabi
let xs: List<i32> = [];
println(f"{xs.len()}");
0

Related: E0040 mismatched types, E0055 literal fits several types

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