mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Fix parsing of if (typeof "foo" === "string")
Move parsing of unary expressions into the primary expression parsing step so that `typeof` takes precedence over `===` in the above example.
This commit is contained in:
parent
7a5ef0a87f
commit
9ee7142227
Notes:
sideshowbarker
2024-07-19 08:08:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9ee71422273
1 changed files with 3 additions and 3 deletions
|
@ -216,6 +216,9 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
|||
|
||||
NonnullRefPtr<Expression> Parser::parse_primary_expression()
|
||||
{
|
||||
if (match_unary_prefixed_expression())
|
||||
return parse_unary_prefixed_expression();
|
||||
|
||||
switch (m_current_token.type()) {
|
||||
case TokenType::ParenOpen: {
|
||||
consume(TokenType::ParenOpen);
|
||||
|
@ -320,9 +323,6 @@ NonnullRefPtr<ArrayExpression> Parser::parse_array_expression()
|
|||
|
||||
NonnullRefPtr<Expression> Parser::parse_expression(int min_precedence, Associativity associativity)
|
||||
{
|
||||
if (match_unary_prefixed_expression())
|
||||
return parse_unary_prefixed_expression();
|
||||
|
||||
auto expression = parse_primary_expression();
|
||||
while (match_secondary_expression()) {
|
||||
int new_precedence = operator_precedence(m_current_token.type());
|
||||
|
|
Loading…
Reference in a new issue