diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index e1cdcb978..a8c970fea 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1850,7 +1850,18 @@ pub fn parse_signature( if bytes.starts_with(b"[") { start += 1; + } else { + error = error.or_else(|| { + Some(ParseError::Expected( + "[".into(), + Span { + start, + end: start + 1, + }, + )) + }); } + if bytes.ends_with(b"]") { end -= 1; } else { diff --git a/src/tests.rs b/src/tests.rs index 1d441cc3e..bdae8b245 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -709,3 +709,8 @@ fn missing_column_error() -> TestResult { "cannot find column", ) } + +#[test] +fn missing_parameters() -> TestResult { + fail_test(r#"def foo {}"#, "expected [") +}