mirror of
https://github.com/nushell/nushell.git
synced 2025-01-24 23:29:52 +01:00
early return for parsing closure and block with interchanged shape (#7618)
This commit is contained in:
parent
27b06358ea
commit
614bc2a943
@ -4176,7 +4176,7 @@ pub fn parse_closure_expression(
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
garbage(span),
|
garbage(span),
|
||||||
Some(ParseError::Expected("block".into(), span)),
|
Some(ParseError::Expected("closure".into(), span)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if bytes.ends_with(b"}") {
|
if bytes.ends_with(b"}") {
|
||||||
@ -4248,7 +4248,7 @@ pub fn parse_closure_expression(
|
|||||||
error = error.or_else(|| {
|
error = error.or_else(|| {
|
||||||
Some(ParseError::Expected(
|
Some(ParseError::Expected(
|
||||||
format!(
|
format!(
|
||||||
"{} block parameter{}",
|
"{} closure parameter{}",
|
||||||
v.len(),
|
v.len(),
|
||||||
if v.len() > 1 { "s" } else { "" }
|
if v.len() > 1 { "s" } else { "" }
|
||||||
),
|
),
|
||||||
|
@ -349,7 +349,10 @@ fn proper_missing_param() -> TestResult {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn block_arity_check1() -> TestResult {
|
fn block_arity_check1() -> TestResult {
|
||||||
fail_test(r#"ls | each { |x, y, z| 1}"#, "expected 2 block parameters")
|
fail_test(
|
||||||
|
r#"ls | each { |x, y, z| 1}"#,
|
||||||
|
"expected 2 closure parameters",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user