ContainsUndefinedContinueTarget needs a BlockStatement implementation #2481
Labels
normative change
Affects behavior required to correctly evaluate some ECMAScript source text
spec bug
web reality
Description: The Static Semantics function
ContainsUndefinedContinueTarget
needs (at least) one more not-default implementation.This function takes two arguments, an iteration_set, which contains labels a continue statement may use, and label_set, a list of labels which might get added to the iteration_set, if they apply to iteration statements.
Specified implementations except for LabelledStatement and BreakableStatement always reset the label_set parameter to the empty list (as it's clear their productions are not iteration statements).
The default implementation, however, does not clear the label set.
Consider:
lbl : { for ( ;; ) continue lbl ; }
This is an undefined continue target. The BlockStatement labelled by
lbl
is not an iteration statement. Web reality produces a syntax error here.The production tree looks like
ContainsUndefinedContinueTarget for the first production adds
lbl
to the label set.All the remaining productions prior to the BreakableStatement use the default implementation.
The BreakableStatement moves the label set (containing
lbl
) into the iteration set and thus makes this label seem like a valid target.(If we actually tried to execute this code, the loop executor functions would actually treat that continue statement like a break statement, and the seemingly infinite loop would actually terminate at the first iteration.)
Fix:
The clearest fix would seem to be to add an implementation for the Statement : BlockStatement production:
This error seems to have been in every ECMAScript spec since the static semantics system was added in ES 6. (In particular, this issue was not due to the recent refactoring of syntax directed operations.)
The text was updated successfully, but these errors were encountered: