-
Notifications
You must be signed in to change notification settings - Fork 207
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
Null handling deficiencies #1543
Comments
Ok on 1, and 4, |
For more discussion on 1 and 4 see https://dart.dev/null-safety/understanding-null-safety#working-with-nullable-fields 2 - I'm not sure if we have an existing issue requestiong 3 - Assertions won't impact flow analysis because they might not happen, and since the null safety is sound it can't be used for flow analysis if it won't necessarily run. You can either use |
cf. #376
|
This is tracked here. |
Closing since I think there isn't anything left to track here. Please follow and 👍 #404 and consider browsing the various proposals at
field-promotion
|
Right now the dart analyser when faced with this:
Will error with nullability because it will tell you that you need to assert that someValue is not null right before the ;. It's obviously not null and any trinary operator case like this should automatically be handled and known.
Second case:
Consider the following function definition:
final bool Function()? someFunction;
In every other language with null safety that I could find I can execute it conditionally like this:
someFunction?() ?? someothervalue;
Dart doesn't allow that, but does allow it if the parent is null with the ?. operator. It should allow the ?() syntax as this gets rid of a TON of cases of having to use the trinary operator.
Third Case:
Because of the assert someObject is known from this point forward to be not null and shouldn't require the ! assertion.
Fourth:
There are numerous cases of If statements where a property must not be null as a result but in the body of the IF it won't know that it can't be null and require ! when it's not possible and you've already handled it.
Please consider correcting all of these cases so that we can stop using ! when it really isn't needed. Thanks!
The text was updated successfully, but these errors were encountered: