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 block scoping transform for declarations in labeled statements #4669
Conversation
Current coverage is 88.78% (diff: 100%)@@ master #4669 diff @@
==========================================
Files 195 195
Lines 13780 13782 +2
Methods 1425 1426 +1
Messages 0 0
Branches 3174 3173 -1
==========================================
+ Hits 12235 12237 +2
Misses 1545 1545
Partials 0 0
|
if (isBlockScoped(node)) { | ||
convertBlockScopedToVar(path, node, block, this.scope); | ||
} | ||
declarators = declarators.concat(node.declarations || 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.
If we are already deduplicating code, then we maybe can also deduplicate this if
? as it basically twice in here I think.
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.
Yeah is this equiv?
const addDeclarationsFromChild = (path, node) => {
node = node || path.node;
if (t.isLabeledStatement(node)) {
node = node.body;
path = path.get("body");
}
if (t.isClassDeclaration(node) || t.isFunctionDeclaration(node) || isBlockScoped(node)) {
if (isBlockScoped(node)) {
convertBlockScopedToVar(path, node, block, this.scope);
}
declarators = declarators.concat(node.declarations || 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.
👍 Did something similar in d276d57. CI is being fussy though: https://travis-ci.org/babel/babel/jobs/165258111#L161
Grumble grumble. Let me try rebasing to latest master.
d276d57
to
14baf0a
Compare
👍 |
…abel#4669) * Fix block scoping transform for declarations in labeled statements (babel#4122) * DRY block-scoping
getLetReferences
between block and switch handling;LabeledStatement
nodes when collecting block-scoped declarations to transform.