Skip to content

Commit 39ffbb0

Browse files
authored
Clarify the compile error for "same" map keys. (#2982)
* Clarify the compile error for "same" map keys. This shouldn't affect the implemented behavior but it avoids an unclear specification corner where two record map keys could or could not be considered the same since record identity is deliberately unspecified. Fix #2979. * Link to record proposal's existing definition of structural equivalence.
1 parent ec8320c commit 39ffbb0

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -621,20 +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.*
624+
* Any two keys in the map are [structurally equivalent][]. *Duplicate
625+
keys are likely to be a copy/paste error. If you want to match the value
626+
associated with some key against multiple patterns, you can always use an
627+
`||` pattern.*s
632628

633629
*Note that `mapPatternEntries` is not optional, which means it is an error for
634630
a map pattern to be empty.*
635631

636-
*Note that we don't require map keys to have primitive equality, to enable
637-
more flexibility in key types.*
632+
[structurally equivalent]: https://github.com/dart-lang/language/blob/master/accepted/future-releases/records/records-feature-specification.md#canonicalization
638633

639634
#### Open and closed maps
640635

0 commit comments

Comments
 (0)