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
[systemjs] Fix nested let
/const
shadowing imported bindings
#14057
Changes from 3 commits
45f4c1f
8199f31
69c067b
a312fe2
15714de
6fe46d8
14e9cfd
aa5593e
aeb81ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,14 @@ const visitor = { | |
> = path.get("declarations"); | ||
let firstId; | ||
|
||
const needsRename = | ||
path.node.kind !== "var" && path.parentPath.isBlockStatement(); | ||
|
||
for (const declar of declarations) { | ||
firstId = declar.node.id; | ||
if (needsRename) { | ||
declar.scope.rename(declar.node.id.name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The TS warning here is correct; I think this breaks, for example, with if (needsRename) {
for (const name of Object.keys(declar.getBindingIdentifiers()) {
declar.scope.rename(name);
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I will do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add a test for this! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I will add the test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it's working now. |
||
} | ||
|
||
if (declar.node.init) { | ||
nodes.push( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { x } from './x.js'; | ||
|
||
if (true) { | ||
const x = 1; | ||
console.log(x); | ||
} | ||
|
||
new (class extends x {})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
System.register(["./x.js"], function (_export, _context) { | ||
"use strict"; | ||
|
||
var x, _x; | ||
|
||
return { | ||
setters: [function (_xJs) { | ||
x = _xJs.x; | ||
}], | ||
execute: function () { | ||
if (true) { | ||
_x = 1; | ||
console.log(_x); | ||
} | ||
|
||
new class extends x {}(); | ||
} | ||
}; | ||
}); |
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.
The hoistVariable visitor should be merged with
environmentVisitor
, too.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.
Lets do it in another PR since it's separate from this bug 👍