-
Notifications
You must be signed in to change notification settings - Fork 28
#2420. Add extension types exhaustiveness tests. Maps #2426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some amount of confusion in the @assertion
and @description
, that should probably be revised (perhaps some older tests have the same?).
In addition to this, I think it would be useful to take the opportunity to test that a switch expression is exhaustive when it exhausts all maps of the given type. This shows that an extension type whose representation type is Map<K, V>
for some K
and V
is actually treated like its representation type during exhaustiveness computations.
LanguageFeatures/Extension-types/exhaustiveness_map_A01_t01.dart
Outdated
Show resolved
Hide resolved
LanguageFeatures/Extension-types/exhaustiveness_map_A01_t01.dart
Outdated
Show resolved
Hide resolved
A very good idea, thank you! Added this tests and updated descriptions/assertions (including original patterns tests). Please take another look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The whole notion of showing that a particular kind of switch expression 'cannot be exhaustive' is questionable: We're promising that we have tried all possible ways to make it exhaustive, and there is no way that works.
The reality is that any attempt to do this would potentially fail because we've forgotten a particularly smart thing that we might have done. So we've found a bunch of switch expressions that aren't exhaustive (not a hard task ;-), but it would then still be false that this kind of pattern 'cannot be exhaustive'.
We do have delicate properties like this (for example: soundness—there is no program that will make a variable of type T
have a value of type S
unless S <: T
"), but they are really difficult to get right in an absolute sense, so we just keep trying to improve on them and eliminate failures (in this case: failures to maintain soundness).
I don't think there's a need to play around with the wording any more, but it's probably a good idea to keep in mind that this kind of quantification over all possible something (all programs, all expressions, whatever) is delicate to get right, and we may just choose to avoid promising anything of that kind, unless we specifically need to do that.
2023-12-19 [email protected] Fixes dart-lang/co19#2441. Fix roll failures (dart-lang/co19#2443) 2023-12-18 [email protected] Fixes dart-lang/co19#2435. Fix roll failures (dart-lang/co19#2437) 2023-12-18 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Variables (dart-lang/co19#2431) 2023-12-15 [email protected] Fixes dart-lang/co19#2430. Update expected errors positions for CFE (dart-lang/co19#2433) 2023-12-15 [email protected] Fixes dart-lang/co19#2432. Remove excessive expected error for CFE (dart-lang/co19#2434) 2023-12-14 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Maps (dart-lang/co19#2426) 2023-12-14 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Lists (dart-lang/co19#2424) 2023-12-14 [email protected] dart-lang/co19#2139. Fix wrong failure of Language/Functions/element_type_A02_t06 (dart-lang/co19#2429) 2023-12-13 [email protected] dart-lang/co19#2350. Add more factory constructors tests (dart-lang/co19#2427) 2023-12-13 [email protected] Fixes dart-lang/co19#2415. Update `StreamController.broadcast()` test according to the changed documentation (dart-lang/co19#2425) 2023-12-13 [email protected] dart-lang/co19#2350. Add/update factory constructor tests. Part 4 (dart-lang/co19#2367) 2023-12-12 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Enums, trivial cases (dart-lang/co19#2423) 2023-12-11 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Enums (dart-lang/co19#2422) 2023-12-11 [email protected] dart-lang/co19#2386. Rename well-bounded tests. Update descriptions (dart-lang/co19#2405) 2023-12-08 [email protected] dart-lang/co19#2415. Change expectations for Stream.asyncMap() according to the current behavior (dart-lang/co19#2421) Change-Id: I777eba4f1615c8477a5d2044f295696dfc210b1d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342582 Commit-Queue: Erik Ernst <[email protected]> Reviewed-by: Alexander Thomas <[email protected]> Reviewed-by: Erik Ernst <[email protected]>
No description provided.