bynk.types.duplicate_pattern_field
Error A record pattern lists the same field twice.
A record pattern lists the fields it reads, and each may be named once. Naming a field twice would bind or test the same value twice, which is almost always a slip for a different field. Keep one mention, and give it the name you want to use, as in total: t. The .. at the end covers every field you leave out.
Example
type Order = { id: String, total: Int }
fn amount(o: Order) -> Int { match o { Order { total, total: t, .. } => t // ✗ `total` is named twice }}
fn amount(o: Order) -> Int { match o { Order { total: t, .. } => t // ✓ }}In the Book
See also
- The grammar rule it governs:
record_pattern. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.duplicate_pattern_fieldshows the same from the installed toolchain, without a network.