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 break/continue when switch is nested inside loop #11802
Conversation
existentialism
commented
Jul 7, 2020
•
edited by JLHwung
edited by JLHwung
Q | A |
---|---|
Fixed Issues? | Fixes #11800, fixes #11690 |
Patch: Bug Fix? | Y |
Tests Added + Pass? | Y |
License | MIT |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d531677:
|
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.
Brilliant! Preserve the break/continue completion by avoiding switch statements.
default: | ||
if (typeof _ret === "object") return _ret.v; | ||
} | ||
if (_ret === "continue") continue; |
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.
Not related to this PR: the string literal here is not minimizer-friendly. We should revise
babel/packages/babel-plugin-transform-block-scoping/src/index.js
Lines 266 to 272 in b1a8e72
function loopNodeTo(node) { | |
if (t.isBreakStatement(node)) { | |
return "break"; | |
} else if (t.isContinueStatement(node)) { | |
return "continue"; | |
} | |
} |
later, e.g. change it to "b"
/"c"
.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/25579/ |
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.
I love when a bugfix is mostly deleted lines