diff options
author | davidot <david.tuin@gmail.com> | 2021-08-14 17:02:15 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-08-16 23:20:04 +0100 |
commit | a8b25d6c36e2824eef954a056f2bf0688d616601 (patch) | |
tree | c0b4c4c0fccf7cfba5b6c2c67f7a9d4ca1019b59 | |
parent | 5f344f7ca3158aa6c5c2e95e95e3f4a58a76dc00 (diff) | |
download | serenity-a8b25d6c36e2824eef954a056f2bf0688d616601.zip |
LibJS: Handle '++' and '--' more correctly within expression
-rw-r--r-- | Userland/Libraries/LibJS/Parser.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 779783106d..303cf457a2 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -1290,7 +1290,7 @@ NonnullRefPtr<Expression> Parser::parse_expression(int min_precedence, Associati Associativity new_associativity = operator_associativity(m_state.current_token.type()); expression = parse_secondary_expression(move(expression), new_precedence, new_associativity); - while (match(TokenType::TemplateLiteralStart)) { + while (match(TokenType::TemplateLiteralStart) && !is<UpdateExpression>(*expression)) { auto template_literal = parse_template_literal(true); expression = create_ast_node<TaggedTemplateLiteral>({ m_state.current_token.filename(), rule_start.position(), position() }, move(expression), move(template_literal)); } @@ -2694,8 +2694,8 @@ bool Parser::match_secondary_expression(const Vector<TokenType>& forbidden) cons || type == TokenType::ParenOpen || type == TokenType::Period || type == TokenType::BracketOpen - || type == TokenType::PlusPlus - || type == TokenType::MinusMinus + || (type == TokenType::PlusPlus && !m_state.current_token.trivia_contains_line_terminator()) + || (type == TokenType::MinusMinus && !m_state.current_token.trivia_contains_line_terminator()) || type == TokenType::In || type == TokenType::Instanceof || type == TokenType::QuestionMark |