LibJS: Parse only AssignmentExpressions in ComputedPropertyNames

The property name in an object literal can either be a literal or a
computed name, in which case any AssignmentExpression can be used, we
now only parse AssignmentExpression instead of the previous incorrect
behaviour which allowed any Expression (Specifically, comma
expressions).
This commit is contained in:
Gal Horowitz 2021-06-11 18:43:28 +03:00 committed by Linus Groh
commit 0e10dec324
Notes: sideshowbarker 2024-07-18 12:25:38 +09:00

View file

@ -783,7 +783,7 @@ NonnullRefPtr<Expression> Parser::parse_property_key()
return create_ast_node<BigIntLiteral>({ m_parser_state.m_current_token.filename(), rule_start.position(), position() }, consume().value());
} else if (match(TokenType::BracketOpen)) {
consume(TokenType::BracketOpen);
auto result = parse_expression(0);
auto result = parse_expression(2);
consume(TokenType::BracketClose);
return result;
} else {