1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:08:13 +00:00

LibJS: Disallow comma after rest parameter in formal parameters

This commit is contained in:
davidot 2021-09-27 22:29:49 +02:00 committed by Linus Groh
parent 7081fb4eb0
commit 9cb5700398

View file

@ -1990,11 +1990,9 @@ Vector<FunctionNode::Parameter> Parser::parse_formal_parameters(int& function_le
syntax_error("Generator function parameter initializer cannot contain a reference to an identifier named \"yield\"");
}
parameters.append({ move(parameter), default_value, is_rest });
if (match(TokenType::ParenClose))
if (match(TokenType::ParenClose) || is_rest)
break;
consume(TokenType::Comma);
if (is_rest)
break;
}
if (parse_options & FunctionNodeParseOptions::IsSetterFunction && parameters.is_empty())
syntax_error("Setter function must have one argument");