-
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
Make ?. smarter #29499
Comments
I don't know if it makes sense to automatically add operators. Though, maybe at minimum this should be a quick-fix in the analyzer? @bwilkerson |
Yeah, a quick fix would be great. |
Strictly speaking, it isn't _always_ useless to have `.` after `?.`. Null
has methods too.
But in practice, I can see what you mean. Instead if having `a?.b.c` just
crash unless `c` is a member of null, why not require `(a?.b).c` when `c`
is a member of null?
This might even be not very breaking change.
|
@MichaelRFairhurst Yes, I know null has methods. But all sense of null that it's a just null. And you never know which one in a chain was null. So, it's still useless. |
Well, its not useless if you intend to use the resulting
This doesn't have the lint error, it recognizes that "null" has "toString", and that "toString" produces "length". That said, it's worth noting that
|
The problem is that the meaning of I too would prefer the whole chain was treated as a null-aware unit. Not only is the current definition mismatched to what many users expect, it also causes the generated code to be bigger and slower than necessary. ( I think we should revisit the definition of |
We are aware of the problem (and I do find it annoying myself :). I hope we'll be able to do something about it at a later point, but sadly it's currently not at the front of the priority queue. What about |
Duplicate of #26240 |
We have long chain like next one:
But Dart Analyzer tells me about warnings, it wants me to write that:
But this additional operators haven't any sense. I guess we should make
?.
operator to skip all next chain and just returnnull
in the end.The text was updated successfully, but these errors were encountered: