Skip to content

fix: rename assignment targets in forXStatement - #18562

Merged
JLHwung merged 1 commit into
babel:mainfrom
JLHwung:fix-renamer-for-x-statement
Nov 10, 2026
Merged

JLHwung merged 1 commit into
babel:mainfrom
JLHwung:fix-renamer-for-x-statement

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 9, 2026

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Fixes #18561 (case 1). Case 2 is already fixed in #18416.
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? 7.x
License MIT

In this PR we fix an issue in the scope renamer: scope.rename renamed the targets of destructuring assignment expressions but not those of a for ({ a } of b) / for ([a] in b) head. getAssignmentIdentifiers already supports for-x-statement, but we need to wire them up in the renamer.

The tests are prepared by LLM and reviewed by myself.

Assisted-by: Claude Opus 5.5

`scope.rename` renamed the targets of destructuring assignment expressions but not those of a `for ({ a } of b)` / `for ([a] in b)` head.

Fixes babel#18561 (case 1)

Assisted-by: Claude Opus 5.5
@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: traverse (scope) 7.x: needs backport labels Nov 9, 2026
@babel-bot

Copy link
Copy Markdown
Collaborator

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 612d238

@JLHwung
JLHwung added this pull request to the merge queue Nov 10, 2026
Merged via the queue into babel:main with commit 1bfd2f2 Nov 10, 2026
99 of 101 checks passed
@JLHwung
JLHwung deleted the fix-renamer-for-x-statement branch November 10, 2026 14:33
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18571.

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

Labels

pkg: traverse (scope) 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.

preset-env: for...of destructuring assigns to a renamed let's old name; nested object rest in an assignment pattern crashes

3 participants