Repository navigation
fix(bytecompiler): continue to an outer label of a multi-labelled loop - #5640
thelastbackspace wants to merge 2 commits into
Conversation
With `a: b: for (...)` only `b` was attached to the loop's jump info, so `continue a` resolved to the labelled statement for `a` and jumped back to its start, re-running the loop initialiser and never terminating. Resolve such a label through the chain of labelled statements to the loop they label. Fixes boa-dev#5633
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5640 +/- ##
===========================================
+ Coverage 47.24% 63.09% +15.85%
===========================================
Files 476 536 +60
Lines 46892 60552 +13660
===========================================
+ Hits 22154 38206 +16052
+ Misses 24738 22346 -2392 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /// A loop can have more than one label (`a: b: for (;;)`), but only the innermost one is | ||
| /// attached to the loop's own jump info; the outer ones are separate labelled-statement infos | ||
| /// pushed right before it. A `continue` to any of them has to continue the loop itself. | ||
| fn continue_target(&self, label: Sym) -> Option<usize> { |
There was a problem hiding this comment.
Suggestion: consider adding the spec steps/link here which relate to this code.
There was a problem hiding this comment.
Added in 1118fdf: links to LabelledEvaluation and LoopContinues, plus a note on how the label set « a, b » reaches the loop, which is why continue a has to continue it just like continue b.
This Pull Request fixes/closes #5633.
With
a: b: for (...), only the innermost label (b) ends up on the loop's jump info.agets its own labelled-statement info just outside it. Socontinue amatched that labelled info and jumped back to the start of the labelled statement. That re-ran the loop initialiser (i = 0), and the loop never finished.continue bwas fine. The title of the issue says it's the second label, but on main it's actually the outer one (continue a) that hangs.It changes the following:
continue <label>now resolves its target up front. If the label belongs to a labelled statement, it walks the chain of directly nested labelled statements down to the loop they label and continues that loop. Anything that isn't a loop falls back to the old behaviour (that's an early error anyway).for,whilewith three labels, andfor-ofwith an inner loop. Each one has a guard counter, so without the fix the test fails instead of hanging.cargo test -p boa_engine --libpasses. I also checkeddo-while,for (let ...)with closures plustry/finally, andbreakto an outer label by hand.