File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -5775,7 +5775,8 @@ pub fn parse_math_expression(
57755775 working_set. error ( ParseError :: IncompleteMathExpression ( spans[ idx - 1 ] ) ) ;
57765776
57775777 expr_stack. push ( Expression :: garbage ( working_set, spans[ idx - 1 ] ) ) ;
5778- expr_stack. push ( Expression :: garbage ( working_set, spans[ idx - 1 ] ) ) ;
5778+ let missing_span = Span :: new ( spans[ idx - 1 ] . end , spans[ idx - 1 ] . end ) ;
5779+ expr_stack. push ( Expression :: garbage ( working_set, missing_span) ) ;
57795780
57805781 break ;
57815782 }
Original file line number Diff line number Diff line change @@ -3146,4 +3146,25 @@ mod record {
31463146 Some ( "Invalid characters after closing delimiter" . to_string( ) )
31473147 ) ;
31483148 }
3149+
3150+ /// https://github.com/nushell/nushell/issues/16713
3151+ #[ test]
3152+ fn garbage_span_of_incomplete_math_op ( ) {
3153+ let engine_state = EngineState :: new ( ) ;
3154+ let mut working_set = StateWorkingSet :: new ( & engine_state) ;
3155+ let block = parse ( & mut working_set, None , b"$ a" , false ) ;
3156+ let pipeline_el_expr = & block
3157+ . pipelines
3158+ . first ( )
3159+ . unwrap ( )
3160+ . elements
3161+ . first ( )
3162+ . unwrap ( )
3163+ . expr
3164+ . expr ;
3165+ let Expr :: BinaryOp ( _, op, rhs) = pipeline_el_expr else {
3166+ panic ! ( "Expected Expr::BinaryOp, but found {pipeline_el_expr:?}" ) ;
3167+ } ;
3168+ assert_ne ! ( op. span, rhs. span)
3169+ }
31493170}
You can’t perform that action at this time.
0 commit comments