From 59f978030e781d6f02e9ca4ffdf0d382d8750bb3 Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Thu, 28 Mar 2024 20:12:54 +0100 Subject: [PATCH] Improve parsing of init expression in for-await-of loops --- acorn/src/statement.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/acorn/src/statement.js b/acorn/src/statement.js index 3b6af1bd..3fe02d36 100644 --- a/acorn/src/statement.js +++ b/acorn/src/statement.js @@ -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)