Skip to content

fix(bytecompiler): continue to an outer label of a multi-labelled loop - #5640

Open
thelastbackspace wants to merge 2 commits into
boa-dev:mainfrom
thelastbackspace:fix/5633-continue-outer-label
Open

thelastbackspace wants to merge 2 commits into
boa-dev:mainfrom
thelastbackspace:fix/5633-continue-outer-label

Conversation

@thelastbackspace

Copy link
Copy Markdown

This Pull Request fixes/closes #5633.

With a: b: for (...), only the innermost label (b) ends up on the loop's jump info. a gets its own labelled-statement info just outside it. So continue a matched 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 b was 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).
  • Adds a regression test covering for, while with three labels, and for-of with an inner loop. Each one has a guard counter, so without the fix the test fails instead of hanging.

cargo test -p boa_engine --lib passes. I also checked do-while, for (let ...) with closures plus try/finally, and break to an outer label by hand.

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
@thelastbackspace
thelastbackspace requested a review from a team as a code owner November 5, 2026 13:18
@github-actions github-actions Bot added Waiting On Review Waiting on reviews from the maintainers C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. labels Nov 5, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Nov 5, 2026
@github-actions

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,578 53,578 0
Passed 51,450 51,450 0
Ignored 1,648 1,648 0
Failed 480 480 0
Panics 0 0 0
Conformance 96.03% 96.03% 0.00%

Tested main commit: bfaa15a7d60d8c92370a423d4134ab19b1b1fae0
Tested PR commit: 04968b7c6c7e7ed2767530d7218319fc0765df92
Compare commits: bfaa15a...04968b7

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.09%. Comparing base (6ddc2b4) to head (04968b7).
⚠️ Report is 1086 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/bytecompiler/statement/continue.rs 93.75% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

/// 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> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: consider adding the spec steps/link here which relate to this code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

continue to the outer label of a label set (a: b: for (…) continue a;) never terminates

2 participants