Rename `array size` to `array count` in error messages.
Using `array count` is closer to the language seen in the spec and clarifies the error messages. Bug: chromium:1367602 Change-Id: I24388496b3a58c6a4fc62cc2db91c7ad8ca1a371 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104241 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
68124ab7d1
commit
ca6fedc96a
|
@ -2601,7 +2601,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) {
|
|||
|
||||
sem::ArrayCount el_count = sem::RuntimeArrayCount{};
|
||||
|
||||
// Evaluate the constant array size expression.
|
||||
// Evaluate the constant array count expression.
|
||||
if (auto* count_expr = arr->count) {
|
||||
if (auto count = ArrayCount(count_expr)) {
|
||||
el_count = count.Get();
|
||||
|
@ -2630,7 +2630,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) {
|
|||
}
|
||||
|
||||
utils::Result<sem::ArrayCount> Resolver::ArrayCount(const ast::Expression* count_expr) {
|
||||
// Evaluate the constant array size expression.
|
||||
// Evaluate the constant array count expression.
|
||||
const auto* count_sem = Materialize(Expression(count_expr));
|
||||
if (!count_sem) {
|
||||
return utils::Failure;
|
||||
|
@ -2648,13 +2648,13 @@ utils::Result<sem::ArrayCount> Resolver::ArrayCount(const ast::Expression* count
|
|||
|
||||
auto* count_val = count_sem->ConstantValue();
|
||||
if (!count_val) {
|
||||
AddError("array size must evaluate to a constant integer expression or override variable",
|
||||
AddError("array count must evaluate to a constant integer expression or override variable",
|
||||
count_expr->source);
|
||||
return utils::Failure;
|
||||
}
|
||||
|
||||
if (auto* ty = count_val->Type(); !ty->is_integer_scalar()) {
|
||||
AddError("array size must evaluate to a constant integer expression, but is type '" +
|
||||
AddError("array count must evaluate to a constant integer expression, but is type '" +
|
||||
builder_->FriendlyName(ty) + "'",
|
||||
count_expr->source);
|
||||
return utils::Failure;
|
||||
|
@ -2662,7 +2662,7 @@ utils::Result<sem::ArrayCount> Resolver::ArrayCount(const ast::Expression* count
|
|||
|
||||
int64_t count = count_val->As<AInt>();
|
||||
if (count < 1) {
|
||||
AddError("array size (" + std::to_string(count) + ") must be greater than 0",
|
||||
AddError("array count (" + std::to_string(count) + ") must be greater than 0",
|
||||
count_expr->source);
|
||||
return utils::Failure;
|
||||
}
|
||||
|
@ -3246,7 +3246,7 @@ bool Resolver::ApplyAddressSpaceUsageToType(ast::AddressSpace address_space,
|
|||
|
||||
auto count = arr->ConstantCount();
|
||||
if (count.has_value() && count.value() >= kMaxArrayElementCount) {
|
||||
AddError("array size (" + std::to_string(count.value()) + ") must be less than " +
|
||||
AddError("array count (" + std::to_string(count.value()) + ") must be less than " +
|
||||
std::to_string(kMaxArrayElementCount),
|
||||
usage);
|
||||
return false;
|
||||
|
|
|
@ -216,28 +216,28 @@ TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Zero) {
|
|||
// var<private> a : array<f32, 0>;
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_a)), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Zero) {
|
||||
// var<private> a : array<f32, 0u>;
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_u)), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Zero) {
|
||||
// var<private> a : array<f32, 0i>;
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_i)), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) {
|
||||
// var<private> a : array<f32, -10i>;
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, -10_i)), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (-10) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (-10) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Zero) {
|
||||
|
@ -246,7 +246,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Zero) {
|
|||
GlobalConst("size", Expr(0_u));
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Zero) {
|
||||
|
@ -255,7 +255,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Zero) {
|
|||
GlobalConst("size", Expr(0_i));
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Negative) {
|
||||
|
@ -264,16 +264,17 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Negative) {
|
|||
GlobalConst("size", Expr(-10_i));
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (-10) must be greater than 0");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array count (-10) must be greater than 0");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
|
||||
// var<private> a : array<f32, 10.0>;
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size must evaluate to a constant integer expression, but is type "
|
||||
"'f32'");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
"12:34 error: array count must evaluate to a constant integer expression, but is type "
|
||||
"'f32'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {
|
||||
|
@ -281,9 +282,10 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {
|
|||
GlobalVar("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2<i32>(), 10_i, 10_i)),
|
||||
ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size must evaluate to a constant integer expression, but is type "
|
||||
"'vec2<i32>'");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
"12:34 error: array count must evaluate to a constant integer expression, but is type "
|
||||
"'vec2<i32>'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_FloatConst) {
|
||||
|
@ -292,9 +294,10 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatConst) {
|
|||
GlobalConst("size", Expr(10_f));
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size must evaluate to a constant integer expression, but is type "
|
||||
"'f32'");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
"12:34 error: array count must evaluate to a constant integer expression, but is type "
|
||||
"'f32'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) {
|
||||
|
@ -303,9 +306,10 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) {
|
|||
GlobalConst("size", Construct(ty.vec2<i32>(), 100_i, 100_i));
|
||||
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size must evaluate to a constant integer expression, but is type "
|
||||
"'vec2<i32>'");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
"12:34 error: array count must evaluate to a constant integer expression, but is type "
|
||||
"'vec2<i32>'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_UnderElementCountLimit) {
|
||||
|
@ -321,7 +325,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_OverElementCountLimit) {
|
|||
ty.array(Source{{12, 34}}, ty.f32(), Expr(Source{{12, 34}}, 65536_a)),
|
||||
ast::AddressSpace::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), R"(1:2 error: array size (65536) must be less than 65536
|
||||
EXPECT_EQ(r()->error(), R"(1:2 error: array count (65536) must be less than 65536
|
||||
1:2 note: while instantiating 'var' a)");
|
||||
}
|
||||
|
||||
|
@ -386,7 +390,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_Override_ComplexExpr) {
|
|||
ast::AddressSpace::kWorkgroup);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size must evaluate to a constant integer expression or override "
|
||||
"12:34 error: array count must evaluate to a constant integer expression or override "
|
||||
"variable");
|
||||
}
|
||||
|
||||
|
@ -545,7 +549,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FunctionLet) {
|
|||
WrapInFunction(size, a);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: array size must evaluate to a constant integer expression or override "
|
||||
"12:34 error: array count must evaluate to a constant integer expression or override "
|
||||
"variable");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue