diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index b1ca82106e..1cf764e23d 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1834,7 +1834,12 @@ pub fn parse_range(working_set: &mut StateWorkingSet, span: Span) -> Option TestResult { @@ -47,7 +48,8 @@ fn zip_ranges() -> TestResult { #[test] fn int_in_stepped_range() -> TestResult { - run_test(r#"7 in 1..3..15"#, "true") + run_test(r#"7 in 1..3..15"#, "true")?; + run_test(r#"7 in 1..3..=15"#, "true") } #[test] @@ -74,3 +76,14 @@ fn float_in_unbounded_stepped_range() -> TestResult { fn float_not_in_unbounded_stepped_range() -> TestResult { run_test(r#"2.1 in 1.2..3.."#, "false") } + +#[rstest] +#[case("1..=3..", "expected number")] +#[case("..=3..=15", "expected number")] +#[case("..=(..", "expected closing )")] +#[case("..=()..", "expected at least one range bound")] +#[case("..=..", "expected at least one range bound")] +#[test] +fn bad_range_syntax(#[case] input: &str, #[case] expect: &str) -> TestResult { + fail_test(&format!("def foo [r: range] {{}}; foo {input}"), expect) +}