From 9a706ea56000327e2cd5d0828385375157d70a1e Mon Sep 17 00:00:00 2001 From: Ariel Don Date: Fri, 27 Oct 2023 12:42:50 -0500 Subject: [PATCH] fix(fe): don't report missing `else` for bad `if` expression --- src/quick-lint-js/fe/parse.h | 2 +- test/test-parse.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/quick-lint-js/fe/parse.h b/src/quick-lint-js/fe/parse.h index 69d55e4f1c..09bd512b17 100644 --- a/src/quick-lint-js/fe/parse.h +++ b/src/quick-lint-js/fe/parse.h @@ -1172,7 +1172,7 @@ void Parser::parse_and_visit_parenthesized_expression( const Char8 *expression_begin = this->peek().begin; - Expression *ast = this->parse_expression(v); + Expression *ast = this->parse_expression(v, {.trailing_identifiers = true}); this->visit_expression(ast, v, Variable_Context::rhs); if constexpr (check_for_sketchy_conditions) { diff --git a/test/test-parse.cpp b/test/test-parse.cpp index 474815828e..2f9dbff235 100644 --- a/test/test-parse.cpp +++ b/test/test-parse.cpp @@ -320,8 +320,9 @@ TEST_F(Test_Parse, utter_garbage) { assert_diagnostics( p.code, p.errors, { - u8" ^ Diag_Expected_Parentheses_Around_If_Condition"_diag, // - u8" ^ Diag_Unexpected_Token"_diag, + u8" ^ Diag_Unexpected_Token"_diag, // + u8" ^^^^^^^^ Diag_Unexpected_Identifier_In_Expression"_diag, // + u8" ^^^^^^^^^^^ Diag_Expected_Parentheses_Around_If_Condition"_diag, }); } }