mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:15:07 +00:00
LibJS: Fix parsing of numeric object keys
Numeric keys were interpreted as their source text, leading to something like {0x10:true} to end up as {"0x10":true} instead of {16:true}
This commit is contained in:
parent
fdacfefd09
commit
be9c2feff0
2 changed files with 9 additions and 4 deletions
|
@ -743,11 +743,9 @@ NonnullRefPtr<Expression> Parser::parse_property_key()
|
|||
if (match(TokenType::StringLiteral)) {
|
||||
return parse_string_literal(consume());
|
||||
} else if (match(TokenType::NumericLiteral)) {
|
||||
// FIXME: "evaluate" key to double value, see https://github.com/SerenityOS/serenity/issues/3717
|
||||
return create_ast_node<StringLiteral>(consume_and_validate_numeric_literal().value());
|
||||
return create_ast_node<NumericLiteral>(consume().double_value());
|
||||
} else if (match(TokenType::BigIntLiteral)) {
|
||||
auto value = consume(TokenType::BigIntLiteral).value();
|
||||
return create_ast_node<StringLiteral>(value.substring_view(0, value.length() - 1));
|
||||
return create_ast_node<BigIntLiteral>(consume().value());
|
||||
} else if (match(TokenType::BracketOpen)) {
|
||||
consume(TokenType::BracketOpen);
|
||||
auto result = parse_expression(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue