Skip to content

Commit

Permalink
Improve parsing of init expression in for-await-of loops
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Mar 28, 2024
1 parent 194bfd8 commit 59f9780
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion acorn/src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ pp.parseForStatement = function(node) {
let startsWithLet = this.isContextual("let"), isForOf = false
let containsEsc = this.containsEsc
let refDestructuringErrors = new DestructuringErrors
let init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors)
let init = awaitAt > -1
? this.parseExprSubscripts(refDestructuringErrors, "await")
: this.parseExpression(true, refDestructuringErrors)
if (this.type === tt._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt)
if (this.type === tt._in) this.unexpected(awaitAt)
Expand Down

0 comments on commit 59f9780

Please sign in to comment.