Improve the error message on the invalid value type of `@blend_src`
This patch improves the error message on the invalid value type of
`@blend_src`.
Bug: chromium:341973423
Test: tint_unittests
Change-Id: If94531dba430b439e99c7f27a41c73a41e0fbc3b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/193081
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/wgsl/resolver/dual_source_blending_extension_test.cc b/src/tint/lang/wgsl/resolver/dual_source_blending_extension_test.cc
index 2817fe9..ded56eb 100644
--- a/src/tint/lang/wgsl/resolver/dual_source_blending_extension_test.cc
+++ b/src/tint/lang/wgsl/resolver/dual_source_blending_extension_test.cc
@@ -57,7 +57,7 @@
DualSourceBlendingExtensionTests() { Enable(wgsl::Extension::kDualSourceBlending); }
};
-// Using an F32 as an index value should fail.
+// Using an F32 as a @blend_src value should fail.
TEST_F(DualSourceBlendingExtensionTests, BlendSrcF32Error) {
Structure("Output", Vector{
Member(Source{{12, 34}}, "a", ty.vec4<f32>(),
@@ -65,17 +65,17 @@
});
EXPECT_FALSE(r()->Resolve());
- EXPECT_EQ(r()->error(), "12:34 error: '@blend_srci32' or 'u32' value");
+ EXPECT_EQ(r()->error(), "12:34 error: '@blend_src' value must be 'i32' or 'u32'");
}
-// Using a floating point number as an index value should fail.
+// Using a floating point number as a @blend_src value should fail.
TEST_F(DualSourceBlendingExtensionTests, BlendSrcFloatValueError) {
Structure("Output", Vector{
Member(Source{{12, 34}}, "a", ty.vec4<f32>(),
Vector{Location(0_a), BlendSrc(Source{{12, 34}}, 1.0_a)}),
});
EXPECT_FALSE(r()->Resolve());
- EXPECT_EQ(r()->error(), "12:34 error: '@blend_srci32' or 'u32' value");
+ EXPECT_EQ(r()->error(), "12:34 error: '@blend_src' value must be 'i32' or 'u32'");
}
// Using a number less than zero as an index value should fail.
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index 7951c47..4b95a76 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -3840,8 +3840,8 @@
}
if (!materialized->Type()->IsAnyOf<core::type::I32, core::type::U32>()) {
- AddError(attr->source) << style::Attribute("@blend_src") << style::Type("i32") << " or "
- << style::Type("u32") << " value";
+ AddError(attr->source) << style::Attribute("@blend_src") << " value must be "
+ << style::Type("i32") << " or " << style::Type("u32");
return Failure{};
}