File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,11 @@ export class MatcherPrinter {
60
60
61
61
* printRangePatternMatcher ( pat : SyntaxNode , target : string ) : Code {
62
62
const [ start , end ] = pat . namedChildren ;
63
- yield `(${ target } >= ${ start . text } && ${ target } <= ${ end . text } )` ;
63
+ yield `(${ target } >= ${ start . text } ` ;
64
+ if ( end ) {
65
+ yield ` && ${ target } <= ${ end . text } ` ;
66
+ }
67
+ yield ")" ;
64
68
}
65
69
66
70
* printSlicePatternMatcher ( pat : SyntaxNode , target : string ) : Code {
Original file line number Diff line number Diff line change @@ -604,12 +604,15 @@ export class Printer {
604
604
}
605
605
606
606
* printRange ( range : SyntaxNode ) : Code {
607
+ const [ start , op , end ] = range . children ;
607
608
yield [ "_r.range(" , range . startPosition ] ;
608
- yield * this . printExpr ( range . child ( 0 ) ! ) ;
609
+ yield * this . printExpr ( start ) ;
609
610
yield [ "," , range . endPosition ] ;
610
- yield * this . printExpr ( range . child ( 2 ) ! ) ;
611
- if ( range . child ( 1 ) ! . type === "..=" ) {
612
- yield [ "+1" , range . endPosition ] ;
611
+ if ( end ) {
612
+ yield * this . printExpr ( end ) ;
613
+ if ( op . type === "..=" ) {
614
+ yield [ "+1" , range . endPosition ] ;
615
+ }
613
616
}
614
617
yield [ ")" , range . endPosition ] ;
615
618
}
You can’t perform that action at this time.
0 commit comments