Skip to content

Merge train: #9548 (loop class captures) - #9549

Merged
proggeramlug merged 2 commits into
mainfrom
land-train75
Sep 2, 2026
Merged

Merge train: #9548 (loop class captures)#9549
proggeramlug merged 2 commits into
mainfrom
land-train75

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Lands #9548 (classic-for per-iteration class captures, #9528) rebased onto main.

Validation: perry-hir 376/0; release build green; fixture byte-identical to node; #9466 shadowed-class fixture as canary also green; no version metadata touched.

Rebase-merge preserving @proggeramlug's authorship.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed class declarations inside for loops so captured let and const values remain associated with the correct iteration.
    • Corrected delayed class methods and field initializers to observe per-iteration values in classic and for-of loops.
    • Preserved shared binding behavior for var loops.

@proggeramlug
proggeramlug merged commit 3a7c0b0 into main Sep 2, 2026
19 of 20 checks passed
@proggeramlug
proggeramlug deleted the land-train75 branch September 2, 2026 16:26
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 2e5a452f-65f4-444f-84b2-1b10d3a7eb07

📥 Commits

Reviewing files that changed from the base of the PR and between 3b9c9de and 5d65905.

📒 Files selected for processing (4)
  • changelog.d/9548-loop-class-captures.md
  • crates/perry-hir/src/lower/shared_mutable_capture.rs
  • crates/perry-hir/src/lower/tests.rs
  • test-files/test_gap_9528_loop_class_capture.ts

📝 Walkthrough

Walkthrough

The lowering now creates a fresh capture cell for each lexical classic-for iteration before the update expression. HIR and runtime tests cover class captures in classic, for-of, and var loops. A changelog entry documents the fix.

Changes

Loop class capture fix

Layer / File(s) Summary
Refresh lexical capture cells
crates/perry-hir/src/lower/shared_mutable_capture.rs
Classic for loops with shared lexical captures now assign a fresh one-element array before the existing update expression.
Validate lowered loop structure
crates/perry-hir/src/lower/tests.rs
HIR tests verify fresh-cell allocation for let loops and shared-cell behavior for var loops.
Cover class capture behavior
test-files/test_gap_9528_loop_class_capture.ts, changelog.d/9548-loop-class-captures.md
Runtime tests cover class captures in classic and for-of loops, plus shared final bindings in var loops. The changelog documents the correction.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: thehypnoo

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch land-train75

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

proggeramlug pushed a commit that referenced this pull request Sep 2, 2026
…over since #9549); re-record diagnostics.rs thread-local count (5->3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant