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