Skip to content

Commit

Permalink
Disallow async functions under labels
Browse files Browse the repository at this point in the history
Closes #716
  • Loading branch information
marijnh committed Aug 6, 2018
1 parent 3ffe903 commit 9856774
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 @@ -385,7 +385,7 @@ pp.parseLabeledStatement = function(node, maybeName, expr) {
node.body = this.parseStatement(true)
if (node.body.type === "ClassDeclaration" ||
node.body.type === "VariableDeclaration" && node.body.kind !== "var" ||
node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator))
node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator || node.body.async))
this.raiseRecoverable(node.body.start, "Invalid labeled declaration")
this.labels.pop()
node.label = expr
Expand Down
2 changes: 2 additions & 0 deletions test/tests-asyncawait.js
Original file line number Diff line number Diff line change
Expand Up @@ -3506,3 +3506,5 @@ test(
)

test("({ async delete() {} })", {}, {ecmaVersion: 8})

testFail("abc: async function a() {}", "Invalid labeled declaration (1:5)", {ecmaVersion: 8})

0 comments on commit 9856774

Please sign in to comment.