Skip to content

Commit 9856774

Browse files
committed
Disallow async functions under labels
Closes #716
1 parent 3ffe903 commit 9856774

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
@@ -385,7 +385,7 @@ pp.parseLabeledStatement = function(node, maybeName, expr) {
385385
node.body = this.parseStatement(true)
386386
if (node.body.type === "ClassDeclaration" ||
387387
node.body.type === "VariableDeclaration" && node.body.kind !== "var" ||
388-
node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator))
388+
node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator || node.body.async))
389389
this.raiseRecoverable(node.body.start, "Invalid labeled declaration")
390390
this.labels.pop()
391391
node.label = expr

test/tests-asyncawait.js

+2
Original file line numberDiff line numberDiff line change
@@ -3506,3 +3506,5 @@ test(
35063506
)
35073507

35083508
test("({ async delete() {} })", {}, {ecmaVersion: 8})
3509+
3510+
testFail("abc: async function a() {}", "Invalid labeled declaration (1:5)", {ecmaVersion: 8})

0 commit comments

Comments
 (0)