diff --git a/crates/nu-parser/src/lex/tests.rs b/crates/nu-parser/src/lex/tests.rs index 73941af08..adca67182 100644 --- a/crates/nu-parser/src/lex/tests.rs +++ b/crates/nu-parser/src/lex/tests.rs @@ -218,7 +218,10 @@ mod lite_parse { #[test] fn incomplete_result() { let (result, err) = lex("my_command \"foo' --test", 10); - assert!(matches!(err.unwrap().reason(), nu_errors::ParseErrorReason::Eof { .. })); + assert!(matches!( + err.unwrap().reason(), + nu_errors::ParseErrorReason::Eof { .. } + )); let (result, _) = block(result); assert_eq!(result.block.len(), 1); diff --git a/crates/nu-parser/src/parse.rs b/crates/nu-parser/src/parse.rs index a0122c226..3054734e9 100644 --- a/crates/nu-parser/src/parse.rs +++ b/crates/nu-parser/src/parse.rs @@ -346,27 +346,26 @@ fn parse_unit(lite_arg: &Spanned) -> (SpannedExpression, Option() { - let lhs_span = - Span::new(lite_arg.span.start(), lite_arg.span.start() + lhs.len()); - let unit_span = - Span::new(lite_arg.span.start() + lhs.len(), lite_arg.span.end()); - return ( - SpannedExpression::new( - Expression::unit(x.spanned(lhs_span), unit_group.0.spanned(unit_span)), - lite_arg.span, - ), - None, - ); - } + // these units are allowed to be signed + if let Ok(x) = lhs.parse::() { + let lhs_span = Span::new(lite_arg.span.start(), lite_arg.span.start() + lhs.len()); + let unit_span = Span::new(lite_arg.span.start() + lhs.len(), lite_arg.span.end()); + return ( + SpannedExpression::new( + Expression::unit(x.spanned(lhs_span), unit_group.0.spanned(unit_span)), + lite_arg.span, + ), + None, + ); } } }