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>>> {
|
) -> impl FnMut(Span<'a>) -> IResult<Span<'a>, Vec<O>, VerboseError<Span<'a>>> {
|
||||||
delimited(
|
delimited(
|
||||||
pair(tok(char('{')), many0(statement_delimiter)),
|
pair(tok(char('{')), many0(statement_delimiter)),
|
||||||
separated_list0(delimiter, input_parser),
|
cut(separated_list0(delimiter, input_parser)),
|
||||||
pair(many0(statement_delimiter), tok(char('}'))),
|
pair(many0(statement_delimiter), tok(char('}'))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn block(input: Span) -> ParseResult<Block> {
|
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> {
|
fn statement(input: Span) -> ParseResult<Statement> {
|
||||||
@ -293,7 +293,8 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
|||||||
"func-signature",
|
"func-signature",
|
||||||
preceded(
|
preceded(
|
||||||
kw("fn"),
|
kw("fn"),
|
||||||
cut(alt((
|
cut(verify(
|
||||||
|
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,
|
||||||
@ -306,7 +307,9 @@ fn func_signature(input: Span) -> ParseResult<Signature> {
|
|||||||
params,
|
params,
|
||||||
type_anno,
|
type_anno,
|
||||||
}),
|
}),
|
||||||
))),
|
)),
|
||||||
|
|sig| sig.params.len() < 256,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
@ -878,12 +878,13 @@ fn custom_operator() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn max_function_params() {
|
fn max_function_params() {
|
||||||
let mut buf = "fn longfunc(".to_string();
|
let mut buf = "fn longfunc(".to_string();
|
||||||
for n in 0..256 {
|
for n in 0..255 {
|
||||||
write!(buf, "a{}, ", n).unwrap();
|
write!(buf, "a{}, ", n).unwrap();
|
||||||
}
|
}
|
||||||
|
write!(buf, " a256").unwrap();
|
||||||
write!(buf, ") {{ return 20 }}").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
|
//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);
|
assert_fail!(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user