Fix function argument limit
This commit is contained in:
parent
bf55e6e82a
commit
032fe5fed9
@ -154,13 +154,13 @@ fn block_template<'a, O, O2>(
|
||||
) -> impl FnMut(Span<'a>) -> IResult<Span<'a>, Vec<O>, VerboseError<Span<'a>>> {
|
||||
delimited(
|
||||
pair(tok(char('{')), many0(statement_delimiter)),
|
||||
separated_list0(delimiter, input_parser),
|
||||
cut(separated_list0(delimiter, input_parser)),
|
||||
pair(many0(statement_delimiter), tok(char('}'))),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn block(input: Span) -> ParseResult<Block> {
|
||||
map(block_template(many1(statement_delimiter), statement), |items| items.into())(input)
|
||||
context("block", map(block_template(many1(statement_delimiter), statement), |items| items.into()))(input)
|
||||
}
|
||||
|
||||
fn statement(input: Span) -> ParseResult<Statement> {
|
||||
@ -293,20 +293,23 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
||||
"func-signature",
|
||||
preceded(
|
||||
kw("fn"),
|
||||
cut(alt((
|
||||
map(normal_fn, |(name, params, type_anno)| Signature {
|
||||
name: rc_string(name.fragment()),
|
||||
operator: false,
|
||||
params,
|
||||
type_anno,
|
||||
}),
|
||||
map(operator_fn, |(op, params, type_anno)| Signature {
|
||||
name: rc_string(op.sigil()),
|
||||
operator: true,
|
||||
params,
|
||||
type_anno,
|
||||
}),
|
||||
))),
|
||||
cut(verify(
|
||||
alt((
|
||||
map(normal_fn, |(name, params, type_anno)| Signature {
|
||||
name: rc_string(name.fragment()),
|
||||
operator: false,
|
||||
params,
|
||||
type_anno,
|
||||
}),
|
||||
map(operator_fn, |(op, params, type_anno)| Signature {
|
||||
name: rc_string(op.sigil()),
|
||||
operator: true,
|
||||
params,
|
||||
type_anno,
|
||||
}),
|
||||
)),
|
||||
|sig| sig.params.len() < 256,
|
||||
)),
|
||||
),
|
||||
)(input)
|
||||
}
|
||||
|
@ -878,12 +878,13 @@ fn custom_operator() {
|
||||
#[test]
|
||||
fn max_function_params() {
|
||||
let mut buf = "fn longfunc(".to_string();
|
||||
for n in 0..256 {
|
||||
for n in 0..255 {
|
||||
write!(buf, "a{}, ", n).unwrap();
|
||||
}
|
||||
write!(buf, " a256").unwrap();
|
||||
write!(buf, ") {{ return 20 }}").unwrap();
|
||||
//assert_fail!(&buf, "A function cannot have more than 255 arguments");
|
||||
//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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user