diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 8e54d536b6..e932d64c18 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -596,6 +596,17 @@ pub fn parse_internal_call( // spans_idx, end, positional_idx // ); + if spans[..end].is_empty() { + error = error.or_else(|| { + Some(ParseError::MissingPositional( + positional.name.clone(), + spans[spans_idx], + )) + }); + positional_idx += 1; + continue; + } + let orig_idx = spans_idx; let (arg, err) = parse_multispan_value( working_set, diff --git a/src/tests/test_parser.rs b/src/tests/test_parser.rs index 0f96c74c14..2bc9b10e84 100644 --- a/src/tests/test_parser.rs +++ b/src/tests/test_parser.rs @@ -118,3 +118,8 @@ fn long_flag() -> TestResult { fn let_not_statement() -> TestResult { fail_test(r#"let x = "hello" | str length"#, "can't") } + +#[test] +fn for_in_missing_var_name() -> TestResult { + fail_test("for in", "missing") +}