mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +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:
parent
3847d00727
commit
664085b719
Notes:
sideshowbarker
2024-07-19 06:00:18 +09:00
Author: https://github.com/mattco98
Commit: 664085b719
Pull-request: https://github.com/SerenityOS/serenity/pull/2435
3 changed files with 6 additions and 2 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue