Skip to content

Commit

Permalink
Let default exported class declarations bind names
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianheine committed Feb 24, 2019
1 parent 637151d commit 196f0cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion acorn/src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ pp.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper)
pp.parseClassId = function(node, isStatement) {
if (this.type === tt.name) {
node.id = this.parseIdent()
if (isStatement === true)
if (isStatement)
this.checkLVal(node.id, BIND_LEXICAL, false)

This comment has been minimized.

Copy link
@jdalton

jdalton Feb 24, 2019

Contributor

What are the possible non-true, but truthy, values of isStatement?

This comment has been minimized.

Copy link
@adrianheine

adrianheine Feb 24, 2019

Author Member

"nullableID" (see 01c6ad2 for context)

} else {
if (isStatement === true)
Expand Down
10 changes: 10 additions & 0 deletions test/tests-harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -4688,6 +4688,16 @@ testFail("export { encrypt }", "Export 'encrypt' is not defined (1:9)", {
sourceType: "module"
});

testFail("class Test {}; export default class Test {}", "Identifier 'Test' has already been declared (1:36)", {
ecmaVersion: 6,
sourceType: "module"
});

test("export default class Test {}; export { Test }", {}, {
ecmaVersion: 6,
sourceType: "module"
});

testFail("export { encrypt, encrypt }", "Duplicate export 'encrypt' (1:18)", {
ecmaVersion: 6,
sourceType: "module"
Expand Down

0 comments on commit 196f0cd

Please sign in to comment.