Skip to content

Commit

Permalink
Make lexical function decls only kick in at top level
Browse files Browse the repository at this point in the history
Issue #714
  • Loading branch information
marijnh committed Aug 6, 2018
1 parent 08b3426 commit 3ffe903
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/tests-harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"})

0 comments on commit 3ffe903

Please sign in to comment.