-
Notifications
You must be signed in to change notification settings - Fork 28
Throwing a null should raise TypeError, not NullThrownError #1553
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
Comments
The null safety specification says:
It doesn't explicitly say what happens for
@leafpetersen Do you agree with this? Example showing that we have void main() async {
if (ct(false)) print("ok"); // "CT: bool"
throw ct("a"); // "CT: dynamic"
}
// Captures static context type.
T ct<T>(Object? value) {
print("CT: $T");
return value as T;
} |
The preference would be to use |
2022-11-29 [email protected] Fixes dart-lang/co19#1553. Replace NullThrowError by TypeError (dart-lang/co19#1557) 2022-11-29 [email protected] dart-lang/co19#1401. [Patterns] List pattern tests added (dart-lang/co19#1552) 2022-11-29 [email protected] Fixes dart-lang/co19#1562. Remove deprecated FallThroughError tests (dart-lang/co19#1563) 2022-11-29 [email protected] Fixes dart-lang/co19#1526. [Records] Expect error for field names that start with underscore (dart-lang/co19#1527) Change-Id: Ia99d047bc85db40b0db3448fbc0aae54ea8a16d4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272641 Commit-Queue: Michael Thomsen <[email protected]> Reviewed-by: Erik Ernst <[email protected]>
2022-12-09 [email protected] dart-lang/co19#1401. [Patterns] List's rest pattern tests (dart-lang/co19#1578) 2022-12-08 [email protected] dart-lang/co19#1575. Update test expectations for analyzer (dart-lang/co19#1576) 2022-12-07 [email protected] dart-lang/co19#1401. [Patterns] Map patterns tests updated. Check primitive == for keys (dart-lang/co19#1574) 2022-12-07 [email protected] dart-lang/co19#1401. [Patterns] Logical and relational patterns tests refactored (dart-lang/co19#1573) 2022-12-06 [email protected] dart-lang/co19#1401. [Patterns] Map pattern tests (dart-lang/co19#1572) 2022-12-02 [email protected] Fixes dart-lang/co19#1553. Description wording fixed (dart-lang/co19#1569) 2022-12-02 [email protected] Fixes dart-lang/co19#1568. Exclude VM-specific test form web-platforms (dart-lang/co19#1570) Change-Id: I69e3d49ac0b244ed12c266bd00a1c3ec9f8e1b45 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274660 Reviewed-by: Alexander Thomas <[email protected]>
In the following text it is expected that throwing the
null
value results inNullThrownError
. In NullSafe mode an attempt to thrownull
should raiseTypeError
instead.cc @lrhn
The text was updated successfully, but these errors were encountered: