From 0e10dec324e30ca138cc8b7b3f37c50075d0a3a0 Mon Sep 17 00:00:00 2001 From: Gal Horowitz Date: Fri, 11 Jun 2021 18:43:28 +0300 Subject: [PATCH] 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). --- Userland/Libraries/LibJS/Parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 9e6e6358b8..125640b003 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -783,7 +783,7 @@ NonnullRefPtr Parser::parse_property_key() return create_ast_node({ 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 {