diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 2a63c4ac5b..0176c83ba0 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -2587,11 +2587,8 @@ std::unique_ptr ParserImpl::func_call_stmt() { return nullptr; } - t = next(); - if (!t.IsParenRight()) { - add_error(t, "missing ) for call statement"); + if (!expect("call statement", Token::Type::kParenRight)) return nullptr; - } return std::make_unique( std::make_unique( @@ -2763,11 +2760,9 @@ std::unique_ptr ParserImpl::postfix_expr( return nullptr; } - t = next(); - if (!t.IsParenRight()) { - add_error(t, "missing ) for call expression"); + if (!expect("call expression", Token::Type::kParenRight)) return nullptr; - } + expr = std::make_unique(source, std::move(prefix), std::move(params)); } else if (t.IsPeriod()) { diff --git a/src/reader/wgsl/parser_impl_call_stmt_test.cc b/src/reader/wgsl/parser_impl_call_stmt_test.cc index 9f567e98eb..2ab8b19550 100644 --- a/src/reader/wgsl/parser_impl_call_stmt_test.cc +++ b/src/reader/wgsl/parser_impl_call_stmt_test.cc @@ -63,7 +63,7 @@ TEST_F(ParserImplTest, Statement_Call_Missing_RightParen) { auto* p = parser("a("); auto e = p->statement(); ASSERT_TRUE(p->has_error()); - EXPECT_EQ(p->error(), "1:3: missing ) for call statement"); + EXPECT_EQ(p->error(), "1:3: expected ')' for call statement"); } TEST_F(ParserImplTest, Statement_Call_Missing_Semi) { @@ -77,7 +77,7 @@ TEST_F(ParserImplTest, Statement_Call_Bad_ArgList) { auto* p = parser("a(b c);"); auto e = p->statement(); ASSERT_TRUE(p->has_error()); - EXPECT_EQ(p->error(), "1:5: missing ) for call statement"); + EXPECT_EQ(p->error(), "1:5: expected ')' for call statement"); } } // namespace diff --git a/src/reader/wgsl/parser_impl_error_msg_test.cc b/src/reader/wgsl/parser_impl_error_msg_test.cc index 73b61d7597..e035f9fb9e 100644 --- a/src/reader/wgsl/parser_impl_error_msg_test.cc +++ b/src/reader/wgsl/parser_impl_error_msg_test.cc @@ -119,14 +119,14 @@ TEST_F(ParserImplErrorTest, BreakStmtMissingSemicolon) { TEST_F(ParserImplErrorTest, CallExprMissingRParen) { EXPECT("fn f() -> void { x = f(1.; }", - "test.wgsl:1:26 error: missing ) for call expression\n" + "test.wgsl:1:26 error: expected ')' for call expression\n" "fn f() -> void { x = f(1.; }\n" " ^\n"); } TEST_F(ParserImplErrorTest, CallStmtMissingRParen) { EXPECT("fn f() -> void { f(1.; }", - "test.wgsl:1:22 error: missing ) for call statement\n" + "test.wgsl:1:22 error: expected ')' for call statement\n" "fn f() -> void { f(1.; }\n" " ^\n"); } diff --git a/src/reader/wgsl/parser_impl_postfix_expression_test.cc b/src/reader/wgsl/parser_impl_postfix_expression_test.cc index 4ec04b2adb..ab16e53c22 100644 --- a/src/reader/wgsl/parser_impl_postfix_expression_test.cc +++ b/src/reader/wgsl/parser_impl_postfix_expression_test.cc @@ -144,7 +144,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_MissingRightParen) { auto e = p->postfix_expression(); ASSERT_TRUE(p->has_error()); ASSERT_EQ(e, nullptr); - EXPECT_EQ(p->error(), "1:3: missing ) for call expression"); + EXPECT_EQ(p->error(), "1:3: expected ')' for call expression"); } TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {