Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1386 from stevenfan/fix-deshadowing-bug
When collecting imported names to deshadow the current ModuleScope, use
  • Loading branch information
Rich-Harris committed Jun 3, 2017
2 parents 21ef61d + 2d30692 commit fc7f23c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/scopes/ModuleScope.js
Expand Up @@ -21,7 +21,7 @@ export default class ModuleScope extends Scope {
if ( specifier.module.isExternal ) return;

specifier.module.getExports().forEach( name => {
names.add( name );
names.add( specifier.module.traceExport(name).name );
});

if ( specifier.name !== '*' ) {
Expand Down
3 changes: 3 additions & 0 deletions test/function/already-deshadowed-import/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'handle already module import names correctly if they are have already been deshadowed'
};
5 changes: 5 additions & 0 deletions test/function/already-deshadowed-import/alice.js
@@ -0,0 +1,5 @@
import * as Bob from "./bob";
export function foo() {
return "alice";
}

4 changes: 4 additions & 0 deletions test/function/already-deshadowed-import/bob.js
@@ -0,0 +1,4 @@
import * as Alice from "./alice";
export function foo() {
return "bob";
}
18 changes: 18 additions & 0 deletions test/function/already-deshadowed-import/main.js
@@ -0,0 +1,18 @@
import * as Bob from "./bob";
import * as Alice from "./alice";

function g() {
var foo = Bob.foo();
return foo;
}

function f() {
var foo = Alice.foo();
return foo;
}

assert.equal(f(), "alice");
assert.equal(g(), "bob");



0 comments on commit fc7f23c

Please sign in to comment.