Parser - Maximum argument count for functions

This commit is contained in:
Emmanuel BENOîT 2023-01-02 15:18:02 +01:00
parent acbce309fa
commit 312cdf18d5

View file

@ -567,6 +567,12 @@ impl Parser {
let mut arguments = Vec::new(); let mut arguments = Vec::new();
if !self.check(&TokenType::RightParen) { if !self.check(&TokenType::RightParen) {
loop { loop {
if arguments.len() == 255 {
return Err(ParserError::new(
self.peek(),
"functions may not have more than 255 arguments",
));
}
arguments.push(self.parse_expression()?); arguments.push(self.parse_expression()?);
if self.expect(&[TokenType::Comma]).is_some() { if self.expect(&[TokenType::Comma]).is_some() {
break; break;