Analyzer: Consider noting failed null promotion in error messages #42388
Labels
legacy-area-analyzer
Use area-devexp instead.
NNBD
Issues related to NNBD Release
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
Milestone
Based on a real example encountered by @yjbanov , consider this example:
The call to
x.isEven
is an error because thex ??= 3
can't promote, because there's an assignment tox
in a closure which could be live on the back edge of the loop. This is easy to miss though, and so it is surprising thatx.isEven
is an error. The error message that the analyzer gives is correct, but doesn't help the user understand why promotion is not kicking in:It seems like at least for error messages around nullability, it might sometimes be feasible to notice that the variable in question was not able to be promoted, and give notice of that in some way, e.g something like:
Not sure if we have enough information lying around to give this kind of feedback, but could be nice if so.
The text was updated successfully, but these errors were encountered: