E4043

E4043#

The record field is defined or matched multiple times.

Erroneous Example#

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

The example above tries to:

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

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

... giving the following error on line 2:

The record field a is defined several times.

... and the following error on line 3:

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

Suggestion#

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

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