docs

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

#E0044: missing field in a literal

A struct or variant literal leaves out a field that has no default. Give every field a value, or declare a default in the struct (n: i32 = 0).

nabi
struct P { x: i32; y: i32; }

let p = P { x: 1 };
error[E0044]: struct `P` is missing field `y` and no default is declared
  --> main.nabi:3:9
   |
 3 | let p = P { x: 1 };
   |         ^^^^^^^^^^

Give the field a value, or declare a default in the struct:

nabi
struct P { x: i32; y: i32 = 0; }

let p = P { x: 1 };
println(f"{p.y}");
0

Related: E0043 no such field, E0045 field given more than once

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