Skip to content

fix: closures in for-loop init capture wrong binding - #18364

Merged
nicolo-ribaudo merged 2 commits into
7.xfrom
automation/backport-18195
Oct 20, 2026
Merged

nicolo-ribaudo merged 2 commits into
7.xfrom
automation/backport-18195

Conversation

@babel-bot

Copy link
Copy Markdown
Collaborator

Backport of #18195 to 7.x

Cherry-picked commits:

Conflicts: Resolved.

  • packages/babel-plugin-transform-block-scoping/src/index.ts: main wraps the visitor in traverse.visitors.merge (with the Annex B visitor) and re-indents the Loop visitor, so the hunk didn't apply. I kept the 7.x structure and manually applied the same change (destructure capturedInHeadClosure/headUsages from getUsageInBody and add the head-closure rename block).

Checks:

  • rebuild: passed.
  • test (full Jest suite): 6 failures, all in packages/babel-code-frame/test/color-detection.js (terminal color detection in the CI environment). These are unrelated to this change; all block-scoping tests pass.
  • lint: ESLint on babel-plugin-transform-block-scoping is clean. The full make lint-ci check-compat-data could not complete in the sandbox (Node OOM in eslint on other packages, and check-compat-data failed with exit 128). Not caused by the backport.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by 🔙 Backport to 7.x for #18195 · copilot · auto · 28.2 AIC · ⌖ 0.658 AIC · ⊞ 9.1K · ◷

@babel-bot

babel-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62410

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: be788d9

@nicolo-ribaudo
nicolo-ribaudo force-pushed the automation/backport-18195 branch from 219df4f to 57790a1 Compare October 20, 2026 15:01
Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.x: backport PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants