From 67473c7a6c05ecfa3ff51108e1b82c91985601f8 Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 12 Aug 2021 03:40:49 +0000 Subject: [PATCH] Add test for var with inferred non-constructible type Follow up to this bugfix: https://dawn-review.googlesource.com/c/tint/+/61660 Change-Id: I357e1fd859c844c3285ea6077c0e58d225e01c6e Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61682 Auto-Submit: James Price Commit-Queue: Ryan Harrison Kokoro: Kokoro Reviewed-by: Ryan Harrison --- src/resolver/var_let_validation_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/resolver/var_let_validation_test.cc b/src/resolver/var_let_validation_test.cc index 43488d10d2..c549f5f11b 100644 --- a/src/resolver/var_let_validation_test.cc +++ b/src/resolver/var_let_validation_test.cc @@ -327,6 +327,20 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Struct_WithAtomic) { "error: function variable must have a constructible type"); } +TEST_F(ResolverVarLetValidationTest, NonConstructibleType_InferredType) { + // [[group(0), binding(0)]] var s : sampler; + // fn foo() { + // var v = s; + // } + Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 0)); + auto* v = Var(Source{{12, 34}}, "v", nullptr, Expr("s")); + WrapInFunction(v); + + EXPECT_FALSE(r()->Resolve()); + EXPECT_EQ(r()->error(), + "12:34 error: function variable must have a constructible type"); +} + } // namespace } // namespace resolver } // namespace tint