diff --git a/src/statement.js b/src/statement.js index 5950608f6..7ac77f1b3 100644 --- a/src/statement.js +++ b/src/statement.js @@ -498,7 +498,7 @@ pp.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { if (isStatement) { node.id = isStatement === "nullableID" && this.type !== tt.name ? null : this.parseIdent() if (node.id) { - this.checkLVal(node.id, this.inModule ? "let" : "var") + this.checkLVal(node.id, this.inModule && !this.inFunction ? "let" : "var") } } diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 5136ff75b..0040e0a51 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -16239,3 +16239,5 @@ test('for ([...foo, bar].baz in qux);', { }, {ecmaVersion: 6}) testFail("var f;\nfunction f() {}", "Identifier 'f' has already been declared (2:9)", {ecmaVersion: 6, sourceType: "module"}); + +test("function f() { var x; function x() {} }", {}, {ecmaVersion: 6, sourceType: "module"})