E4043

E4043#

The struct field is defined or matched multiple times.

Erroneous Example#

pub struct S {
  a : Int
}

pub let a : Int = match S::{ a: 2, a: 3 } {
  { a: 2, a: 3 } => 4
  _ => 5
}

The example above tries to:

  1. Create a struct with the field a defined multiple times.

  2. Destructure a struct with the field a matched multiple times.

... giving the following error on line 2:

The struct field a is defined several times.

... and the following error on line 3:

The struct field a is matched several times in this pattern.

Suggestion#

Make sure that the struct field is defined or matched only once:

pub struct S {
  a : Int
}

pub let a : Int = match S::{ a: 2 } {
  { a: 2 } => 4
  _ => 5
}