@@ -369,18 +369,6 @@ pp.parseNamedArrowFromCallExpression = function (node, call) {
369
369
return this . finishNode ( node , isMember ? "NamedArrowMemberExpression" : "NamedArrowExpression" ) ;
370
370
} ;
371
371
372
- pp . pushBlockState = function ( blockType , indentLevel ) {
373
- this . state . blockStack . push ( { blockType, indentLevel } ) ;
374
- } ;
375
-
376
- pp . matchBlockState = function ( blockType , indentLevel ) {
377
- return this . state . blockStack . some ( ( x ) => x . blockType === blockType && x . indentLevel === indentLevel ) ;
378
- } ;
379
-
380
- pp . popBlockState = function ( ) {
381
- this . state . blockStack . pop ( ) ;
382
- } ;
383
-
384
372
// c/p parseIfStatement
385
373
386
374
pp . parseIf = function ( node , isExpression ) {
@@ -389,7 +377,7 @@ pp.parseIf = function (node, isExpression) {
389
377
node . test = this . parseParenExpression ( ) ;
390
378
391
379
const isColon = this . match ( tt . colon ) ;
392
- if ( isColon ) this . pushBlockState ( "if" , indentLevel ) ;
380
+ if ( isColon ) this . state . ifWhiteBlockStack . push ( indentLevel ) ;
393
381
394
382
if ( isExpression ) {
395
383
if ( this . match ( tt . braceL ) ) {
@@ -405,7 +393,7 @@ pp.parseIf = function (node, isExpression) {
405
393
406
394
node . alternate = this . parseIfAlternate ( node , isExpression , isColon , indentLevel ) ;
407
395
408
- if ( isColon ) this . popBlockState ( ) ;
396
+ if ( isColon ) this . state . ifWhiteBlockStack . pop ( ) ;
409
397
410
398
return this . finishNode ( node , isExpression ? "IfExpression" : "IfStatement" ) ;
411
399
} ;
@@ -417,11 +405,9 @@ pp.parseIfAlternate = function (node, isExpression, ifIsWhiteBlock, ifIndentLeve
417
405
// it matches with a whiteblock `if` higher on the stack, then this alternate
418
406
// clause does not match the current `if` -- so unwind the recursive descent.
419
407
const alternateIndentLevel = this . state . indentLevel ;
420
- if (
421
- ( alternateIndentLevel !== ifIndentLevel ) &&
422
- ( ifIsWhiteBlock || this . matchBlockState ( "if" , alternateIndentLevel ) )
423
- ) {
424
- return null ;
408
+ if ( alternateIndentLevel !== ifIndentLevel ) {
409
+ if ( ifIsWhiteBlock ) return null ;
410
+ if ( this . state . ifWhiteBlockStack . some ( x => x === alternateIndentLevel ) ) return null ;
425
411
}
426
412
427
413
if ( this . match ( tt . _elif ) ) {
0 commit comments