mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +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
1 changed files with 3 additions and 3 deletions
|
@ -216,6 +216,9 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
||||||
|
|
||||||
NonnullRefPtr<Expression> Parser::parse_primary_expression()
|
NonnullRefPtr<Expression> Parser::parse_primary_expression()
|
||||||
{
|
{
|
||||||
|
if (match_unary_prefixed_expression())
|
||||||
|
return parse_unary_prefixed_expression();
|
||||||
|
|
||||||
switch (m_current_token.type()) {
|
switch (m_current_token.type()) {
|
||||||
case TokenType::ParenOpen: {
|
case TokenType::ParenOpen: {
|
||||||
consume(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)
|
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();
|
auto expression = parse_primary_expression();
|
||||||
while (match_secondary_expression()) {
|
while (match_secondary_expression()) {
|
||||||
int new_precedence = operator_precedence(m_current_token.type());
|
int new_precedence = operator_precedence(m_current_token.type());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue