diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 76aae57c01..e5cc9bcdc8 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -246,5 +246,23 @@ TEST_F(ValidateFunctionTest, FunctionVarInitWithParam) { EXPECT_TRUE(v.Validate()) << v.error(); } +TEST_F(ValidateFunctionTest, FunctionConstInitWithParam) { + // fn foo(bar : f32) -> void{ + // const baz : f32 = bar; + // } + + auto* bar = Var("bar", ty.f32(), ast::StorageClass::kFunction); + auto* baz = Const("baz", ty.f32(), Expr("bar")); + + Func("foo", ast::VariableList{bar}, ty.void_(), ast::StatementList{Decl(baz)}, + ast::DecorationList{ + create(ast::PipelineStage::kVertex), + }); + + ValidatorImpl& v = Build(); + + EXPECT_TRUE(v.Validate()) << v.error(); +} + } // namespace } // namespace tint