(this: Parser, node: Undone<N.For>)
| 827 | // is a regular `for` loop. |
| 828 | |
| 829 | parseForStatement(this: Parser, node: Undone<N.For>): N.For { |
| 830 | this.next(); |
| 831 | this.state.labels.push(loopLabel); |
| 832 | |
| 833 | let awaitAt = null; |
| 834 | |
| 835 | if (this.isContextual(tt._await) && this.recordAwaitIfAllowed()) { |
| 836 | awaitAt = this.state.startLoc; |
| 837 | this.next(); |
| 838 | } |
| 839 | this.scope.enter(ScopeFlag.OTHER); |
| 840 | this.expect(tt.parenL); |
| 841 | |
| 842 | if (this.match(tt.semi)) { |
| 843 | if (awaitAt !== null) { |
| 844 | this.unexpected(awaitAt); |
| 845 | } |
| 846 | return this.parseFor(node, null); |
| 847 | } |
| 848 | |
| 849 | const startsWithLet = this.isContextual(tt._let); |
| 850 | { |
| 851 | const startsWithAwaitUsing = this.isAwaitUsing(); |
| 852 | const starsWithUsingDeclaration = |
| 853 | startsWithAwaitUsing || this.isForUsing(); |
| 854 | const isLetOrUsing = |
| 855 | (startsWithLet && this.hasFollowingBindingAtom()) || |
| 856 | starsWithUsingDeclaration; |
| 857 | |
| 858 | if (this.match(tt._var) || this.match(tt._const) || isLetOrUsing) { |
| 859 | const initNode = this.startNode<N.VariableDeclaration>(); |
| 860 | let kind; |
| 861 | if (startsWithAwaitUsing) { |
| 862 | kind = "await using"; |
| 863 | if (!this.recordAwaitIfAllowed()) { |
| 864 | this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc); |
| 865 | } |
| 866 | this.next(); // eat 'await' |
| 867 | } else { |
| 868 | kind = this.state.value; |
| 869 | } |
| 870 | this.next(); |
| 871 | this.parseVar(initNode, true, kind); |
| 872 | const init = this.finishNode(initNode, "VariableDeclaration"); |
| 873 | |
| 874 | const isForIn = this.match(tt._in); |
| 875 | if (isForIn && starsWithUsingDeclaration) { |
| 876 | this.raise(Errors.ForInUsing, init); |
| 877 | } |
| 878 | if ( |
| 879 | (isForIn || this.isContextual(tt._of)) && |
| 880 | init.declarations.length === 1 |
| 881 | ) { |
| 882 | return this.parseForX(node as Undone<N.ForXStatement>, init, awaitAt); |
| 883 | } |
| 884 | if (awaitAt !== null) { |
| 885 | this.unexpected(awaitAt); |
| 886 | } |
nothing calls this directly
no test coverage detected