Skip to content

Commit 32c1785

Browse files
committed
Fix regression
1 parent 59f9780 commit 32c1785

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

acorn/src/statement.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pp.parseForStatement = function(node) {
237237
let startsWithLet = this.isContextual("let"), isForOf = false
238238
let containsEsc = this.containsEsc
239239
let refDestructuringErrors = new DestructuringErrors
240+
let initPos = this.start
240241
let init = awaitAt > -1
241242
? this.parseExprSubscripts(refDestructuringErrors, "await")
242243
: this.parseExpression(true, refDestructuringErrors)
@@ -245,7 +246,7 @@ pp.parseForStatement = function(node) {
245246
if (this.type === tt._in) this.unexpected(awaitAt)
246247
node.await = true
247248
} else if (isForOf && this.options.ecmaVersion >= 8) {
248-
if (!containsEsc && init.type === "Identifier" && init.name === "async") this.unexpected()
249+
if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") this.unexpected()
249250
else if (this.options.ecmaVersion >= 9) node.await = false
250251
}
251252
if (startsWithLet && isForOf) this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'.")

test/tests-async-iteration.js

+1
Original file line numberDiff line numberDiff line change
@@ -2000,3 +2000,4 @@ testFail("for (async of [1]) {}", "Unexpected token (1:14)", {ecmaVersion: 9})
20002000

20012001
testFail("async () => { for (async\nof []); }", "Unexpected token (2:0)", {ecmaVersion: 9})
20022002
testFail("async () => { for (async of\n[]); }", "Unexpected token (2:0)", {ecmaVersion: 9})
2003+
test("for ((async) of [7]);", {}, {ecmaVersion: 9})

0 commit comments

Comments
 (0)