fix module binding resolution - fixes #762
This commit is contained in:
parent
a567531f77
commit
ce332b3384
@ -141,7 +141,7 @@ Scope.prototype.checkBlockScopedCollisions = function (kind, name, id) {
|
|||||||
if (kind === "param") return;
|
if (kind === "param") return;
|
||||||
if (kind === "hoisted" && local.kind === "let") return;
|
if (kind === "hoisted" && local.kind === "let") return;
|
||||||
|
|
||||||
if (local.kind === "let" || local.kind === "const") {
|
if (local.kind === "let" || local.kind === "const" || local.kind === "module") {
|
||||||
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
|
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -22,6 +22,9 @@
|
|||||||
"FunctionDeclaration": ["Statement", "Declaration", "Scopable", "Function"],
|
"FunctionDeclaration": ["Statement", "Declaration", "Scopable", "Function"],
|
||||||
"FunctionExpression": ["Scopable", "Function", "Expression"],
|
"FunctionExpression": ["Scopable", "Function", "Expression"],
|
||||||
|
|
||||||
|
"ImportSpecifier": ["ModuleSpecifier"],
|
||||||
|
"ExportSpecifier": ["ModuleSpecifier"],
|
||||||
|
|
||||||
"BlockStatement": ["Statement", "Scopable"],
|
"BlockStatement": ["Statement", "Scopable"],
|
||||||
"Program": ["Scopable"],
|
"Program": ["Scopable"],
|
||||||
"CatchClause": ["Scopable"],
|
"CatchClause": ["Scopable"],
|
||||||
|
|||||||
@ -590,6 +590,8 @@ t.getBindingIdentifiers = function (node) {
|
|||||||
|
|
||||||
if (t.isIdentifier(id)) {
|
if (t.isIdentifier(id)) {
|
||||||
ids[id.name] = id;
|
ids[id.name] = id;
|
||||||
|
} else if (t.isModuleSpecifier(id)) {
|
||||||
|
search.push(id.name || id.id);
|
||||||
} else if (t.isExportDeclaration(id)) {
|
} else if (t.isExportDeclaration(id)) {
|
||||||
if (t.isDeclaration(node.declaration)) {
|
if (t.isDeclaration(node.declaration)) {
|
||||||
search.push(node.declaration);
|
search.push(node.declaration);
|
||||||
@ -608,8 +610,6 @@ t.getBindingIdentifiers = function (node) {
|
|||||||
t.getBindingIdentifiers.keys = {
|
t.getBindingIdentifiers.keys = {
|
||||||
AssignmentExpression: ["left"],
|
AssignmentExpression: ["left"],
|
||||||
ImportBatchSpecifier: ["name"],
|
ImportBatchSpecifier: ["name"],
|
||||||
ImportSpecifier: ["name", "id"],
|
|
||||||
ExportSpecifier: ["name", "id"],
|
|
||||||
VariableDeclarator: ["id"],
|
VariableDeclarator: ["id"],
|
||||||
FunctionDeclaration: ["id"],
|
FunctionDeclaration: ["id"],
|
||||||
ClassDeclaration: ["id"],
|
ClassDeclaration: ["id"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user