@@ -4430,14 +4430,14 @@ export const utils = (( ) => {
4430
4430
const parts = [ 0 ] ;
4431
4431
let discard = false ;
4432
4432
4433
- const shouldDiscard = ( ) => stack . some ( v => v ) ;
4433
+ const shouldDiscard = ( ) => stack . some ( v => v . known && v . discard ) ;
4434
4434
4435
- const begif = ( startDiscard , match ) => {
4436
- if ( discard === false && startDiscard ) {
4437
- parts . push ( match . index ) ;
4435
+ const begif = details => {
4436
+ if ( discard === false && details . known && details . discard ) {
4437
+ parts . push ( details . pos ) ;
4438
4438
discard = true ;
4439
4439
}
4440
- stack . push ( startDiscard ) ;
4440
+ stack . push ( details ) ;
4441
4441
} ;
4442
4442
4443
4443
const endif = match => {
@@ -4455,15 +4455,21 @@ export const utils = (( ) => {
4455
4455
4456
4456
switch ( match [ 1 ] ) {
4457
4457
case 'if' : {
4458
- const startDiscard = this . evaluateExpr ( match [ 2 ] . trim ( ) , env ) === false ;
4459
- begif ( startDiscard , match ) ;
4458
+ const result = this . evaluateExpr ( match [ 2 ] . trim ( ) , env ) ;
4459
+ begif ( {
4460
+ known : result !== undefined ,
4461
+ discard : result === false ,
4462
+ pos : match . index ,
4463
+ } ) ;
4460
4464
break ;
4461
4465
}
4462
4466
case 'else' : {
4463
4467
if ( stack . length === 0 ) { break ; }
4464
- const startDiscard = stack [ stack . length - 1 ] === false ;
4468
+ const details = stack [ stack . length - 1 ] ;
4465
4469
endif ( match ) ;
4466
- begif ( startDiscard , match ) ;
4470
+ details . discard = details . discard === false ;
4471
+ details . pos = match . index ;
4472
+ begif ( details ) ;
4467
4473
break ;
4468
4474
}
4469
4475
case 'endif' : {
0 commit comments