mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibJS: Fix conditional expression precedence
This fixes the following from parsing incorrectly due to the comma
that occurs after the conditional:
let o = {
foo: true ? 1 : 2,
bar: 'baz',
};
This commit is contained in:
committed by
Andreas Kling
parent
3847d00727
commit
664085b719
@@ -1105,9 +1105,9 @@ NonnullRefPtr<ContinueStatement> Parser::parse_continue_statement()
|
||||
NonnullRefPtr<ConditionalExpression> Parser::parse_conditional_expression(NonnullRefPtr<Expression> test)
|
||||
{
|
||||
consume(TokenType::QuestionMark);
|
||||
auto consequent = parse_expression(0);
|
||||
auto consequent = parse_expression(2);
|
||||
consume(TokenType::Colon);
|
||||
auto alternate = parse_expression(0);
|
||||
auto alternate = parse_expression(2);
|
||||
return create_ast_node<ConditionalExpression>(move(test), move(consequent), move(alternate));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user