Skip to content

Commit 2cd1d9a

Browse files
committed
Treat function declarations in modules as lexical
Closes #714
1 parent a7dd5fa commit 2cd1d9a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/statement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pp.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) {
498498
if (isStatement) {
499499
node.id = isStatement === "nullableID" && this.type !== tt.name ? null : this.parseIdent()
500500
if (node.id) {
501-
this.checkLVal(node.id, "var")
501+
this.checkLVal(node.id, this.inModule ? "let" : "var")
502502
}
503503
}
504504

test/tests-harmony.js

+2
Original file line numberDiff line numberDiff line change
@@ -16237,3 +16237,5 @@ test('for ([...foo, bar].baz in qux);', {
1623716237
],
1623816238
"sourceType": "script"
1623916239
}, {ecmaVersion: 6})
16240+
16241+
testFail("var f;\nfunction f() {}", "Identifier 'f' has already been declared (2:9)", {ecmaVersion: 6, sourceType: "module"});

0 commit comments

Comments
 (0)