-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Dart2js accepts "null" as argument to "!". #34147
Comments
Will |
Yes, the type expected by conditions and boolean operators will (overwhelmingly likely) be non-null All these operations currently throw if they get a null value (exept when implementations forget to check), so they are prime examples of operations whose operands will become non-nullable. |
Note that dart2js fails to raise a dynamic error because null occurs where a I just tried another one (using dart2js from ac4eca7): main() {
print("Before loop");
while (null) {
print("In loop!");
break;
}
print("After loop");
} Surprisingly, this prints 'Before loop', then 'After loop', and then once more 'After loop'. With do-while, main() {
print("Before loop");
do {
print("In loop!");
break;
} while (null);
print("After loop");
} |
This helps triage/resolve issues in testRuntimeErrors: * if_null_condition_test will be an approved failure for all dart2js configurations due to #34147. * if_runtime_error_test contains all the expected type errors. On the dart2js-production-linux-d8 configuration (which runs with -O3), we assume no type errors exist - even ones guarded by Expect.throwsTypeError - so the optimized code produces runtime errors instead. See https://dart-review.googlesource.com/c/sdk/+/97820 for a similar discussion. Change-Id: Iaf2df85af16cc03fcd7ec7ef2a9e57a2bc3ce081 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98622 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Mayank Patke <fishythefish@google.com>
https://dart-review.googlesource.com/c/sdk/+/98780 should fix this. |
Example:
The text was updated successfully, but these errors were encountered: