docs

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

#E0045: field given more than once

A struct literal names the same field twice. Remove one.

nabi
struct P { x: i32 }

let p = P { x: 1, x: 2 };
error[E0045]: field `x` specified more than once in `P` literal
  --> main.nabi:3:9
   |
 3 | let p = P { x: 1, x: 2 };
   |         ^^^^^^^^^^^^^^^^

Give the field once:

nabi
struct P { x: i32 }

let p = P { x: 2 };
println(f"{p.x}");
2

Related: E0044 missing field in a literal, E0049 invalid named argument

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