Unsound treatment of label: break label;
in type/flow analysis
#50294
Labels
dart-model-analyzer-spec
Issues with the analyzer's implementation of the language spec
legacy-area-analyzer
Use area-devexp instead.
legacy-area-front-end
Legacy: Use area-dart-model instead.
P2
A bug or feature request we're likely to work on
soundness
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Uh oh!
There was an error while loading. Please reload this page.
Take some ridiculous code like:
This code compiles and prints
Gotcha
anddouble
.If I change
label: break label;
to the supposedly completely equivalentlabel: { break label; }
, it stops compiling, because the flow analysis correctly deduces thatlabel: { break label; }
can terminate normally.The
label: break label;
is mistakenly seen as not terminating. Code immediately after it is considered dead code by the analyzer. Type promotion assumes it never completes.This affects both analyzer and front-end.
(Guessing we are doing something special with lables, maybe storing them on the inner statement's AST node instead of making a labeled statement a proper composite statement with its own AST node, which makes it much easier to forget that they can be on any statement. Especially since it only matters for composite statements which can contain a
break
orcontinue
. Which includesbreak
statements.)(Found while looking at dart-lang/language#2586).
The text was updated successfully, but these errors were encountered: