Skip to content

Commit bd5bb32

Browse files
authored
Re-add error for duplicate keys in map patterns. (#2969)
1 parent f56f6eb commit bd5bb32

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

accepted/future-releases/0546-patterns/feature-specification.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Author: Bob Nystrom
44

55
Status: Accepted
66

7-
Version 2.29 (see [CHANGELOG](#CHANGELOG) at end)
7+
Version 2.30 (see [CHANGELOG](#CHANGELOG) at end)
88

99
Note: This proposal is broken into a couple of separate documents. See also
1010
[records][] and [exhaustiveness][].
@@ -621,6 +621,15 @@ It is a compile-time error if:
621621
expressions in a future release without it being a breaking change, similar
622622
to default values in parameter lists.*
623623

624+
* Any two keys in the map are identical. *Duplicate keys are likely to be a
625+
copy/paste error. If you want to match the value associated with some key
626+
against multiple patterns, you can always use an `||` pattern.*s
627+
628+
* Any two record keys which both have primitive equality are equal. *Since
629+
records don't have defined identity, we can't use the previous rule to
630+
detect identical records. But records do support an equality test known at
631+
compile time if all of their fields do, so we use that.*
632+
624633
*Note that `mapPatternEntries` is not optional, which means it is an error for
625634
a map pattern to be empty.*
626635

@@ -3501,6 +3510,10 @@ Here is one way it could be broken down into separate pieces:
35013510
35023511
## Changelog
35033512
3513+
### 2.30
3514+
3515+
- Re-add error for map patterns to have duplicate keys.
3516+
35043517
### 2.29
35053518
35063519
- Map patterns no longer check length.

0 commit comments

Comments
 (0)