@@ -595,27 +595,29 @@ It is a compile-time error if:
595595
596596* Any of the entry key expressions are not constant expressions.
597597
598- * If any two keys in the map are identical. * Map patterns that don't have a
599- rest element only match if the ` length ` of the map is equal to the number of
600- map entries. If a map pattern has multiple identical key entries, they will
598+ * Any two keys in the map are identical. * Map patterns that don't have a rest
599+ element only match if the ` length ` of the map is equal to the number of map
600+ entries. If a map pattern has multiple identical key entries, they will
601601 increase the required length for the pattern to match but in all but the
602602 most perverse ` Map ` implementations will represent the same key. Thus, it's
603603 very unlikely that any map pattern containing identical keys (and no rest
604604 element) will ever match. Duplicate keys are most likely a typo in the
605605 code.*
606606
607- * If any two keys in the map both have primitive ` == ` methods, then it is a
608- compile-time error if they are equal according to their ` == ` operator. * In
609- cases where keys have types whose equality can be checked at compile time,
610- we report errors if there are redundant keys. But we don't require the keys
611- to have primitive equality for flexibility. In map patterns where the keys
612- don't have primitive equality, it is possible to have redundant keys and the
613- compiler won't detect it.*
607+ * Any two record keys which both have primitive ` == ` are equal. * Since
608+ records don't have defined identity, we can't use the previous rule to
609+ detect identical records. But records do support an equality test known at
610+ compile time if all of their fields do, so we use that.*
614611
615612* There is more than one ` ... ` element in the map pattern.
616613
617614* The ` ... ` element is not the last element in the map pattern.
618615
616+ * Note that we don't require map keys to have primitive ` == ` methods to enable
617+ more flexibility in key types. If the keys have user-defined ` == ` methods, then
618+ it's possible to have keys that are equal according to those ` == ` methods, but
619+ the compiler won't detect it.*
620+
619621### Rest elements
620622
621623Like lists, map patterns can also have a rest element. However, there's no
@@ -3221,6 +3223,8 @@ Here is one way it could be broken down into separate pieces:
32213223
32223224- Clarify which variables are valid in pattern assignments.
32233225
3226+ - Clarify when primitive `==` for map pattern keys comes into play (#2690).
3227+
32243228### 2.19
32253229
32263230- Specify exhaustiveness checking of switch elements.
0 commit comments