1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

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
parent 8b3f8879c1
commit 0e10dec324

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 {