@@ -546,7 +546,6 @@ private void ConsumeSemicolon()
546546 _lastMarker . Line = _startMarker . Line ;
547547 _lastMarker . Column = _startMarker . Column ;
548548 }
549-
550549 }
551550
552551 // https://tc39.github.io/ecma262/#sec-primary-expression
@@ -2938,7 +2937,7 @@ private Statement ParseForStatement()
29382937 var forIn = true ;
29392938 Node ? left = null ;
29402939 Expression ? right = null ;
2941- var _await = false ;
2940+ var @await = false ;
29422941
29432942 var node = CreateNode ( ) ;
29442943 ExpectKeyword ( "for" ) ;
@@ -2948,14 +2947,19 @@ private Statement ParseForStatement()
29482947 {
29492948 TolerateUnexpectedToken ( _lookahead ) ;
29502949 }
2951- _await = true ;
2950+ @await = true ;
29522951 NextToken ( ) ;
29532952 }
29542953
29552954 Expect ( "(" ) ;
29562955
29572956 if ( Match ( ";" ) )
29582957 {
2958+ if ( @await )
2959+ {
2960+ TolerateUnexpectedToken ( _lookahead ) ;
2961+ }
2962+
29592963 NextToken ( ) ;
29602964 }
29612965 else
@@ -2971,8 +2975,13 @@ private Statement ParseForStatement()
29712975 var declarations = ParseVariableDeclarationList ( ref inFor ) ;
29722976 _context . AllowIn = previousAllowIn ;
29732977
2974- if ( ! _await && declarations . Count == 1 && MatchKeyword ( "in" ) )
2978+ if ( declarations . Count == 1 && MatchKeyword ( "in" ) )
29752979 {
2980+ if ( @await )
2981+ {
2982+ TolerateUnexpectedToken ( _lookahead ) ;
2983+ }
2984+
29762985 var decl = declarations [ 0 ] ;
29772986 if ( decl . Init != null && ( decl . Id . Type == Nodes . ArrayPattern || decl . Id . Type == Nodes . ObjectPattern || _context . Strict ) )
29782987 {
@@ -2994,6 +3003,11 @@ private Statement ParseForStatement()
29943003 }
29953004 else
29963005 {
3006+ if ( @await )
3007+ {
3008+ TolerateUnexpectedToken ( _lookahead ) ;
3009+ }
3010+
29973011 init = Finalize ( initNode , new VariableDeclaration ( declarations , VariableDeclarationKind . Var ) ) ;
29983012 Expect ( ";" ) ;
29993013 }
@@ -3005,6 +3019,11 @@ private Statement ParseForStatement()
30053019 var kind = ParseVariableDeclarationKind ( kindString ) ;
30063020 if ( ! _context . Strict && ( string ? ) _lookahead . Value == "in" )
30073021 {
3022+ if ( @await )
3023+ {
3024+ TolerateUnexpectedToken ( _lookahead ) ;
3025+ }
3026+
30083027 left = Finalize ( initNode , new Identifier ( kindString ) ) ;
30093028 NextToken ( ) ;
30103029 right = ParseExpression ( ) ;
@@ -3020,6 +3039,11 @@ private Statement ParseForStatement()
30203039
30213040 if ( declarations . Count == 1 && declarations [ 0 ] ! . Init == null && MatchKeyword ( "in" ) )
30223041 {
3042+ if ( @await )
3043+ {
3044+ TolerateUnexpectedToken ( _lookahead ) ;
3045+ }
3046+
30233047 left = Finalize ( initNode , new VariableDeclaration ( declarations , kind ) ) ;
30243048 NextToken ( ) ;
30253049 right = ParseExpression ( ) ;
@@ -3035,6 +3059,11 @@ private Statement ParseForStatement()
30353059 }
30363060 else
30373061 {
3062+ if ( @await )
3063+ {
3064+ TolerateUnexpectedToken ( _lookahead ) ;
3065+ }
3066+
30383067 ConsumeSemicolon ( ) ;
30393068 init = Finalize ( initNode , new VariableDeclaration ( declarations , kind ) ) ;
30403069 }
@@ -3054,6 +3083,11 @@ private Statement ParseForStatement()
30543083
30553084 if ( MatchKeyword ( "in" ) )
30563085 {
3086+ if ( @await )
3087+ {
3088+ TolerateUnexpectedToken ( _lookahead ) ;
3089+ }
3090+
30573091 if ( ! _context . IsAssignmentTarget || init . Type == Nodes . AssignmentExpression )
30583092 {
30593093 TolerateError ( Messages . InvalidLHSInForIn ) ;
@@ -3081,6 +3115,11 @@ private Statement ParseForStatement()
30813115 }
30823116 else
30833117 {
3118+ if ( @await )
3119+ {
3120+ TolerateUnexpectedToken ( _lookahead ) ;
3121+ }
3122+
30843123 // The `init` node was not parsed isolated, but we would have wanted it to.
30853124 _context . IsBindingElement = previousIsBindingElement ;
30863125 _context . IsAssignmentTarget = previousIsAssignmentTarget ;
@@ -3135,8 +3174,8 @@ private Statement ParseForStatement()
31353174 return left == null
31363175 ? Finalize ( node , new ForStatement ( init , test , update , body ) )
31373176 : forIn
3138- ? Finalize ( node , new ForInStatement ( left , right ! , body ) )
3139- : Finalize ( node , new ForOfStatement ( left , right ! , body , _await ) ) ;
3177+ ? ( Statement ) Finalize ( node , new ForInStatement ( left , right ! , body ) )
3178+ : Finalize ( node , new ForOfStatement ( left , right ! , body , @await ) ) ;
31403179 }
31413180
31423181 // https://tc39.github.io/ecma262/#sec-continue-statement
0 commit comments