(
this: Parser,
node: Undone<N.ForXStatement>,
init:
| N.VariableDeclaration
| N.AssignmentPattern
| N.Identifier
| N.MemberExpression,
awaitAt?: Position | null,
)
| 1357 | // same from parser's perspective. |
| 1358 | |
| 1359 | parseForX( |
| 1360 | this: Parser, |
| 1361 | node: Undone<N.ForXStatement>, |
| 1362 | init: |
| 1363 | | N.VariableDeclaration |
| 1364 | | N.AssignmentPattern |
| 1365 | | N.Identifier |
| 1366 | | N.MemberExpression, |
| 1367 | awaitAt?: Position | null, |
| 1368 | ): N.ForXStatement { |
| 1369 | const isForIn = this.match(tt._in); |
| 1370 | this.next(); |
| 1371 | |
| 1372 | if (isForIn) { |
| 1373 | if (awaitAt !== null) this.unexpected(awaitAt); |
| 1374 | } else { |
| 1375 | (node as Undone<N.ForOfStatement>).await = awaitAt !== null; |
| 1376 | } |
| 1377 | |
| 1378 | if ( |
| 1379 | init.type === "VariableDeclaration" && |
| 1380 | init.declarations[0].init != null && |
| 1381 | (!isForIn || |
| 1382 | !this.options.annexB || |
| 1383 | this.state.strict || |
| 1384 | init.kind !== "var" || |
| 1385 | init.declarations[0].id.type !== "Identifier") |
| 1386 | ) { |
| 1387 | this.raise(Errors.ForInOfLoopInitializer, init, { |
| 1388 | type: isForIn ? "ForInStatement" : "ForOfStatement", |
| 1389 | }); |
| 1390 | } |
| 1391 | |
| 1392 | if (init.type === "AssignmentPattern") { |
| 1393 | this.raise(Errors.InvalidLhs, init, { |
| 1394 | ancestor: { type: "ForStatement" }, |
| 1395 | }); |
| 1396 | } |
| 1397 | |
| 1398 | node.left = init as N.VariableDeclaration; |
| 1399 | node.right = isForIn |
| 1400 | ? this.parseExpression() |
| 1401 | : this.parseMaybeAssignAllowIn(); |
| 1402 | this.expect(tt.parenR); |
| 1403 | |
| 1404 | // Parse the loop body. |
| 1405 | node.body = this.parseStatement(); |
| 1406 | |
| 1407 | this.scope.exit(); |
| 1408 | this.state.labels.pop(); |
| 1409 | |
| 1410 | return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement"); |
| 1411 | } |
| 1412 | |
| 1413 | // Parse a list of variable declarations. |
| 1414 |
nothing calls this directly
no test coverage detected