Allow for and other commands missing positionals near keywords (#606)

* Allow for and other commands missing positionals near keywords

* A bit more resilience
This commit is contained in:
JT 2021-12-28 07:04:48 +11:00 committed by GitHub
parent 5c94528fe2
commit 384ea111eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -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,

View file

@ -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")
}