1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibJS: Allow assignment expression in spreading property definition

See: https://tc39.es/ecma262/#sec-runtime-semantics-propertydefinitionevaluation
PropertyDefinition : ... AssignmentExpression
Also add a test for this in array spreading, which already had this in
place.
This commit is contained in:
Luke Wilde 2023-08-29 21:38:42 +01:00 committed by Tim Flynn
parent 766cd852d3
commit 3ceedbd16a
3 changed files with 41 additions and 1 deletions

View file

@ -1926,7 +1926,7 @@ NonnullRefPtr<ObjectExpression const> Parser::parse_object_expression()
if (match(TokenType::TripleDot)) {
consume();
property_key = parse_expression(4);
property_key = parse_expression(2);
properties.append(create_ast_node<ObjectProperty>({ m_source_code, rule_start.position(), position() }, *property_key, nullptr, ObjectProperty::Type::Spread, false));
if (!match(TokenType::Comma))
break;