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
Conversation
liuxingbaoyu
commented
Mar 25, 2024
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 |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56574 |
} | ||
} | ||
|
||
function w2() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
. :)
There was a problem hiding this comment.
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 }) |
There was a problem hiding this comment.
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?
forX
in loopfor X
in loop