Update test for 2.29/2.30 changes to map patterns.

It is still an error to have duplicate keys.

Change-Id: Id86fa7b50c3620540f4bef0399f5f70316848662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292125
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom 2023-03-31 01:30:54 +00:00 committed by Commit Queue
parent 4cd53dbb2e
commit 15e5ec93f3
2 changed files with 2 additions and 12 deletions

View file

@ -38,9 +38,8 @@ main() {
case {'b': _}:
print('b');
case {'a': _, 'b': _}:
// ^
// [analyzer] unspecified
// [cfe] This case is covered by the previous cases.
// ^^^^
// [analyzer] HINT.UNREACHABLE_SWITCH_CASE
print('a b');
}
}

View file

@ -12,15 +12,6 @@ import "package:expect/expect.dart";
main() {
var map = {'a': 1, 'b': 2};
// Map patterns are allowed to have identical keys.
Expect.isTrue(switch (map) { {'a': _, 'a': _} => true, _ => false });
// Map patterns are allowed to have primitive equal record keys.
Expect.isTrue(switch ({('c', 'd'): 3}) {
{('c', 'd'): _, ('c', 'd'): _} => true,
_ => false
});
// Map patterns don't access length.
Expect.isTrue(
switch (NoLengthMap(map)) { {'a': _, 'a': _} => true, _ => false });