From 196f0cd3688b8031741b188f4f5f4b30bc7395b8 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 24 Feb 2019 20:43:37 +0100 Subject: [PATCH] Let default exported class declarations bind names --- acorn/src/statement.js | 2 +- test/tests-harmony.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/acorn/src/statement.js b/acorn/src/statement.js index 632048449..23a903840 100644 --- a/acorn/src/statement.js +++ b/acorn/src/statement.js @@ -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) } else { if (isStatement === true) diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 249a708b7..e37047489 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -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"