From c5cd6b9eb0f11a8ff6d4ee6213c1ec2d8dd9ced0 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 18 Jun 2021 14:53:13 +0000 Subject: [PATCH] validation: add test for function params behave as const decl Bug: tint:257 Change-Id: Ia5cdde240ecd2fa17dfeb08872037c18004fce06 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54821 Auto-Submit: Sarah Mashayekhi Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Sarah Mashayekhi --- src/resolver/function_validation_test.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/resolver/function_validation_test.cc b/src/resolver/function_validation_test.cc index 4f0cf4016e..ca4c0a9095 100644 --- a/src/resolver/function_validation_test.cc +++ b/src/resolver/function_validation_test.cc @@ -331,6 +331,14 @@ TEST_F(ResolverFunctionValidationTest, FunctionConstInitWithParam) { EXPECT_TRUE(r()->Resolve()) << r()->error(); } +TEST_F(ResolverFunctionValidationTest, FunctionParamsConst) { + Func("foo", {Param(Sym("arg"), ty.i32())}, ty.void_(), + {Assign(Expr(Source{{12, 34}}, "arg"), Expr(1)), Return()}); + + EXPECT_FALSE(r()->Resolve()); + EXPECT_EQ(r()->error(), "12:34 error: cannot assign to value of type 'i32'"); +} + TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_BadType) { // [[stage(compute), workgroup_size(64.0)] // fn main() {}