@@ -1417,7 +1417,7 @@ private WithStatement ParseWithStmt() {
14171417 var withItem = ParseWithItem ( ) ;
14181418 List < WithItem > items = null ;
14191419 while ( MaybeEat ( TokenKind . Comma ) ) {
1420- if ( items == null ) {
1420+ if ( items is null ) {
14211421 items = new List < WithItem > ( ) ;
14221422 }
14231423
@@ -1427,7 +1427,7 @@ private WithStatement ParseWithStmt() {
14271427
14281428 var header = GetEnd ( ) ;
14291429 Statement body = ParseSuite ( ) ;
1430- if ( items != null ) {
1430+ if ( items is not null ) {
14311431 for ( int i = items . Count - 1 ; i >= 0 ; i -- ) {
14321432 var curItem = items [ i ] ;
14331433 var innerWith = new WithStatement ( curItem . ContextManager , curItem . Variable , body ) ;
@@ -1480,12 +1480,34 @@ private AsyncWithStatement ParseAsyncWithStmt(int asyncStart) {
14801480 }
14811481
14821482 Eat ( TokenKind . KeywordWith ) ;
1483+
14831484 var withItem = ParseWithItem ( ) ;
1485+ List < WithItem > items = null ;
1486+ while ( MaybeEat ( TokenKind . Comma ) ) {
1487+ if ( items is null ) {
1488+ items = new List < WithItem > ( ) ;
1489+ }
1490+
1491+ items . Add ( ParseWithItem ( ) ) ;
1492+ }
1493+
1494+
14841495 var header = GetEnd ( ) ;
14851496 Statement body = ParseSuite ( ) ;
1497+ if ( items is not null ) {
1498+ for ( int i = items . Count - 1 ; i >= 0 ; i -- ) {
1499+ var curItem = items [ i ] ;
1500+ var innerWith = new AsyncWithStatement ( curItem . ContextManager , curItem . Variable , body ) ;
1501+ innerWith . HeaderIndex = header ;
1502+ innerWith . SetLoc ( _globalParent , withItem . Start , GetEnd ( ) ) ;
1503+ body = innerWith ;
1504+ header = GetEnd ( ) ;
1505+ }
1506+ }
1507+
14861508 AsyncWithStatement ret = new AsyncWithStatement ( withItem . ContextManager , withItem . Variable , body ) ;
14871509 ret . HeaderIndex = header ;
1488- ret . SetLoc ( _globalParent , asyncStart , GetEnd ( ) ) ;
1510+ ret . SetLoc ( _globalParent , withItem . Start , GetEnd ( ) ) ;
14891511 return ret ;
14901512 }
14911513
0 commit comments