Apply 256 arg limit to lambdas too
This commit is contained in:
parent
7221d2cb11
commit
fc463d3807
@ -293,8 +293,7 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
|||||||
"func-signature",
|
"func-signature",
|
||||||
preceded(
|
preceded(
|
||||||
kw("fn"),
|
kw("fn"),
|
||||||
cut(verify(
|
cut(alt((
|
||||||
alt((
|
|
||||||
map(normal_fn, |(name, params, type_anno)| Signature {
|
map(normal_fn, |(name, params, type_anno)| Signature {
|
||||||
name: rc_string(name.fragment()),
|
name: rc_string(name.fragment()),
|
||||||
operator: false,
|
operator: false,
|
||||||
@ -307,18 +306,21 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
|||||||
params,
|
params,
|
||||||
type_anno,
|
type_anno,
|
||||||
}),
|
}),
|
||||||
)),
|
))),
|
||||||
|sig| sig.params.len() < 256,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn formal_params(input: Span) -> ParseResult<Vec<FormalParam>> {
|
fn formal_params(input: Span) -> ParseResult<Vec<FormalParam>> {
|
||||||
delimited(tok(char('(')), separated_list0(tok(char(',')), formal_param), tok(char(')')))(input)
|
context(
|
||||||
|
"formal-params",
|
||||||
|
verify(
|
||||||
|
delimited(tok(char('(')), separated_list0(tok(char(',')), formal_param), tok(char(')'))),
|
||||||
|
|params: &Vec<_>| params.len() < 256,
|
||||||
|
),
|
||||||
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO support 256-limit
|
|
||||||
fn formal_param(input: Span) -> ParseResult<FormalParam> {
|
fn formal_param(input: Span) -> ParseResult<FormalParam> {
|
||||||
map(
|
map(
|
||||||
tuple((identifier, opt(type_anno), opt(preceded(tok(char('=')), expression)))),
|
tuple((identifier, opt(type_anno), opt(preceded(tok(char('=')), expression)))),
|
||||||
|
@ -886,6 +886,14 @@ fn max_function_params() {
|
|||||||
//TODO need to create a good, custom error message for this case
|
//TODO need to create a good, custom error message for this case
|
||||||
//assert_fail!(&buf, "A function cannot have more than 255 arguments");
|
//assert_fail!(&buf, "A function cannot have more than 255 arguments");
|
||||||
assert_fail!(&buf);
|
assert_fail!(&buf);
|
||||||
|
|
||||||
|
let mut buf = r#"\("#.to_string();
|
||||||
|
for n in 0..255 {
|
||||||
|
write!(buf, "a{}, ", n).unwrap();
|
||||||
|
}
|
||||||
|
write!(buf, " a256").unwrap();
|
||||||
|
write!(buf, ") {{ return 10 }}").unwrap();
|
||||||
|
assert_fail!(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user