register named method id as a reference to avoid collisions - fixes #1664

This commit is contained in:
Sebastian McKenzie
2015-06-01 21:53:34 +01:00
parent 8919fc22b1
commit 80a7f13460
5 changed files with 29 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ var wrap = function (state, method, id, scope) {
}
method.id = id;
scope.getProgramParent().references[id.name] = true;
};
var visit = function (node, name, scope) {

View File

@@ -70,6 +70,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
t.variableDeclarator(variableName, ref)
]));
} else {
console.log(variableName.name);
// import { foo } from "foo";
this.internalRemap[variableName.name] = t.memberExpression(ref, specifier.imported);
}

View File

@@ -44,12 +44,6 @@ var collectorVisitor = {
}
},
Scopable(node, parent, scope) {
for (var name in scope.bindings) {
scope.getProgramParent().references[name] = true;
}
},
ExportDeclaration: {
exit(node, parent, scope) {
var declar = node.declaration;
@@ -459,6 +453,7 @@ export default class Scope {
return;
}
var parent = this.getProgramParent();
var ids = path.getBindingIdentifiers();
for (var name in ids) {
@@ -470,6 +465,8 @@ export default class Scope {
this.checkBlockScopedCollisions(local, kind, name, id);
}
parent.references[name] = true;
this.bindings[name] = new Binding({
identifier: id,
scope: this,