forked from extern/nushell
Soften the block arity checking (#5135)
This commit is contained in:
parent
aaec840b91
commit
0b85938415
@ -3630,7 +3630,7 @@ pub fn parse_block_expression(
|
||||
// TODO: Finish this
|
||||
if let SyntaxShape::Block(Some(v)) = shape {
|
||||
if let Some((sig, sig_span)) = &signature {
|
||||
if sig.num_positionals() != v.len() {
|
||||
if sig.num_positionals() > v.len() {
|
||||
error = error.or_else(|| {
|
||||
Some(ParseError::Expected(
|
||||
format!(
|
||||
@ -3657,20 +3657,6 @@ pub fn parse_block_expression(
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if !v.is_empty() {
|
||||
error = error.or_else(|| {
|
||||
Some(ParseError::Expected(
|
||||
format!(
|
||||
"{} block parameter{}",
|
||||
v.len(),
|
||||
if v.len() > 1 { "s" } else { "" }
|
||||
),
|
||||
Span {
|
||||
start: span.start + 1,
|
||||
end: span.start + 1,
|
||||
},
|
||||
))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,16 +330,6 @@ fn proper_missing_param() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn block_arity_check1() -> TestResult {
|
||||
fail_test(r#"ls | each { 1 }"#, "expected 1 block parameter")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn block_arity_check2() -> TestResult {
|
||||
fail_test(r#"ls | reduce { 1 }"#, "expected 2 block parameters")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn block_arity_check3() -> TestResult {
|
||||
fail_test(r#"ls | each { |x, y| 1}"#, "expected 1 block parameter")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user