LibJS: Disallow multiple parameters in paren-less arrow function

Fixes #2323.
This commit is contained in:
Linus Groh 2020-05-21 23:45:53 +01:00 committed by Andreas Kling
parent 84b508befa
commit 27913154ea
Notes: sideshowbarker 2024-07-19 06:16:03 +09:00
2 changed files with 6 additions and 1 deletions

View file

@ -287,7 +287,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
i32 function_length = -1;
while (true) {
if (match(TokenType::Comma)) {
if (has_rest_parameter) {
if (has_rest_parameter || !expect_parens) {
parse_failed = true;
break;
}

View file

@ -55,6 +55,11 @@ try {
})(10);
assert(half === 5);
var foo, bar;
foo = bar, baz => {};
assert(foo === undefined);
assert(bar === undefined);
console.log("PASS");
} catch {
console.log("FAIL");