1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibJS: Allow patterns in parenthesized arrow function parameters

This commit is contained in:
Ali Mohammad Pur 2021-07-02 15:21:46 +04:30 committed by Andreas Kling
parent 2e00731ddb
commit ccbc54358d
2 changed files with 10 additions and 1 deletions

View file

@ -645,7 +645,9 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
case TokenType::ParenOpen: {
auto paren_position = position();
consume(TokenType::ParenOpen);
if ((match(TokenType::ParenClose) || match(TokenType::Identifier) || match(TokenType::TripleDot)) && !try_parse_arrow_function_expression_failed_at_position(paren_position)) {
if ((match(TokenType::ParenClose) || match(TokenType::Identifier) || match(TokenType::TripleDot) || match(TokenType::CurlyOpen) || match(TokenType::BracketOpen))
&& !try_parse_arrow_function_expression_failed_at_position(paren_position)) {
auto arrow_function_result = try_parse_arrow_function_expression(true);
if (!arrow_function_result.is_null())
return { arrow_function_result.release_nonnull() };