Skip to content

Commit

Permalink
Fix duplicate export checking
Browse files Browse the repository at this point in the history
To actually look at the exported names, and to properly
call raiseRecoverable.

Closes #463
  • Loading branch information
marijnh committed Sep 8, 2016
1 parent 44f0925 commit 5ab4935
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ pp.parseExport = function(node, exports) {
return this.finishNode(node, "ExportAllDeclaration")
}
if (this.eat(tt._default)) { // export default ...
pp.checkExport(exports, "default", this.lastTokStart)
this.checkExport(exports, "default", this.lastTokStart)
let parens = this.type == tt.parenL
let expr = this.parseMaybeAssign()
let needsSemi = true
Expand Down Expand Up @@ -660,8 +660,8 @@ pp.parseExportSpecifiers = function(exports) {

let node = this.startNode()
node.local = this.parseIdent(this.type === tt._default)
this.checkExport(exports, node.local.name, node.local.start)
node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local
this.checkExport(exports, node.exported.name, node.exported.start)
nodes.push(this.finishNode(node, "ExportSpecifier"))
}
return nodes
Expand Down
11 changes: 11 additions & 0 deletions test/tests-harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -15062,3 +15062,14 @@ testFail("function* wrap() {\nclass A {*yield() {}}\n}", "Can not use 'yield' as

// invalid syntax '*foo: 1'
testFail("({*foo: 1})", "Unexpected token (1:6)", {ecmaVersion: 6})

test("export { x as y } from './y.js';\nexport { x as z } from './z.js';",
{}, {sourceType: "module", ecmaVersion: 6})

test("export { default as y } from './y.js';\nexport default 42;",
{}, {sourceType: "module", ecmaVersion: 6})


testFail("export { default} from './y.js';\nexport default 42;",
"Duplicate export 'default' (2:7)",
{sourceType: "module", ecmaVersion: 6})

0 comments on commit 5ab4935

Please sign in to comment.