Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Transform scoping for for X in loop #16384

Merged
merged 2 commits into from Mar 27, 2024

Conversation

liuxingbaoyu
Copy link
Member

Q                       A
Fixed Issues? Fixes #16382
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass?
Documentation PR Link
Any Dependency Changes?
License MIT

@liuxingbaoyu liuxingbaoyu added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Mar 25, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented Mar 25, 2024

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

}
}

function w2() {
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between these two functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

One is for in and the other is for of. :)

Copy link
Member

Choose a reason for hiding this comment

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

Ohh I played the "find the difference between the two pictures" game for like 3 minutes before giving up 😬

assign.length === 1 ? assign[0] : t.sequenceExpression(assign);
if (
!t.isForStatement(varPath.parent, { init: varPath.node }) &&
!t.isForXStatement(varPath.parent, { left: varPath.node })
Copy link
Member

Choose a reason for hiding this comment

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

Can you also add a test swapping the for ... in and for (;;) loops?

@liuxingbaoyu liuxingbaoyu changed the title fix: Transform scoping for forX in loop fix: Transform scoping for for X in loop Mar 25, 2024
@JLHwung JLHwung merged commit a0b1653 into babel:main Mar 27, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[Bug]: Transform block scoping fails with for in statement inside loop
4 participants