Remove the `type` keyword.

`type` has been deprecated in favour of `alias`. This CL removes the
deprecation warning and moves `type` to a reserved word.

Bug: tint:1812
Change-Id: I05246b9887a0890ae8343a0a132bd6f93353d5ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120540
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-02-21 16:55:07 +00:00 committed by Dawn LUCI CQ
parent db9d4453f8
commit 21571709a2
25 changed files with 78 additions and 195 deletions

View File

@ -6,6 +6,7 @@
* The `sig` member of the return type of `frexp()` has been renamed to `fract`. [tint:1766](crbug.com/tint/1766) * The `sig` member of the return type of `frexp()` has been renamed to `fract`. [tint:1766](crbug.com/tint/1766)
* Calling a function with multiple pointer arguments that alias each other is now a error. [tint:1675](crbug.com/tint/1675) * Calling a function with multiple pointer arguments that alias each other is now a error. [tint:1675](crbug.com/tint/1675)
* `type` deprecation has been removed. `alias` must be used now. [tint:1812](crbug.com/tint/1812)
## Changes for M111 ## Changes for M111

View File

@ -79,7 +79,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
const std::vector<uint32_t> components, const std::vector<uint32_t> components,
std::ostringstream& shaderSource, std::ostringstream& shaderSource,
std::ostringstream& shaderBody) { std::ostringstream& shaderBody) {
shaderSource << "type StencilValues = array<u32, " << components.size() << ">;\n"; shaderSource << "alias StencilValues = array<u32, " << components.size() << ">;\n";
shaderSource << R"( shaderSource << R"(
struct DepthResult { struct DepthResult {
value : f32 value : f32

View File

@ -42,8 +42,8 @@ struct S1 {
const c0 : i32 = 10; const c0 : i32 = 10;
const c1 : bool = true; const c1 : bool = true;
type t0 = array<vec4<f32>>; alias t0 = array<vec4<f32>>;
type t1 = array<vec4<f32>>; alias t1 = array<vec4<f32>>;
var<private> g0 : u32 = 20u; var<private> g0 : u32 = 20u;
var<private> g1 : f32 = 123.0; var<private> g1 : f32 = 123.0;
@ -111,11 +111,11 @@ fn main() {
const declaration_order_check_0 : i32 = 1; const declaration_order_check_0 : i32 = 1;
type declaration_order_check_1 = f32; alias declaration_order_check_1 = f32;
fn declaration_order_check_2() {} fn declaration_order_check_2() {}
type declaration_order_check_3 = f32; alias declaration_order_check_3 = f32;
const declaration_order_check_4 : i32 = 1; const declaration_order_check_4 : i32 = 1;

View File

@ -1193,9 +1193,6 @@ Token Lexer::check_keyword(const Source& source, std::string_view str) {
if (str == "true") { if (str == "true") {
return {Token::Type::kTrue, source, "true"}; return {Token::Type::kTrue, source, "true"};
} }
if (str == "type") {
return {Token::Type::kType, source, "type"};
}
if (str == "var") { if (str == "var") {
return {Token::Type::kVar, source, "var"}; return {Token::Type::kVar, source, "var"};
} }

View File

@ -1082,7 +1082,6 @@ INSTANTIATE_TEST_SUITE_P(LexerTest,
TokenData{"struct", Token::Type::kStruct}, TokenData{"struct", Token::Type::kStruct},
TokenData{"switch", Token::Type::kSwitch}, TokenData{"switch", Token::Type::kSwitch},
TokenData{"true", Token::Type::kTrue}, TokenData{"true", Token::Type::kTrue},
TokenData{"type", Token::Type::kType},
TokenData{"var", Token::Type::kVar}, TokenData{"var", Token::Type::kVar},
TokenData{"while", Token::Type::kWhile})); TokenData{"while", Token::Type::kWhile}));

View File

@ -99,10 +99,11 @@ bool is_reserved(const Token& t) {
t == "signed" || t == "sizeof" || t == "smooth" || t == "snorm" || t == "static" || t == "signed" || t == "sizeof" || t == "smooth" || t == "snorm" || t == "static" ||
t == "static_cast" || t == "std" || t == "subroutine" || t == "super" || t == "target" || t == "static_cast" || t == "std" || t == "subroutine" || t == "super" || t == "target" ||
t == "template" || t == "this" || t == "thread_local" || t == "throw" || t == "trait" || t == "template" || t == "this" || t == "thread_local" || t == "throw" || t == "trait" ||
t == "try" || t == "typedef" || t == "typeid" || t == "typename" || t == "typeof" || t == "try" || t == "type" || t == "typedef" || t == "typeid" || t == "typename" ||
t == "union" || t == "unless" || t == "unorm" || t == "unsafe" || t == "unsized" || t == "typeof" || t == "union" || t == "unless" || t == "unorm" || t == "unsafe" ||
t == "use" || t == "using" || t == "varying" || t == "virtual" || t == "volatile" || t == "unsized" || t == "use" || t == "using" || t == "varying" || t == "virtual" ||
t == "wgsl" || t == "where" || t == "with" || t == "writeonly" || t == "yield"; t == "volatile" || t == "wgsl" || t == "where" || t == "with" || t == "writeonly" ||
t == "yield";
} }
/// Enter-exit counters for block token types. /// Enter-exit counters for block token types.
@ -774,12 +775,7 @@ Maybe<ParserImpl::VariableQualifier> ParserImpl::variable_qualifier() {
// : ALIAS IDENT EQUAL type_specifier // : ALIAS IDENT EQUAL type_specifier
Maybe<const ast::Alias*> ParserImpl::type_alias_decl() { Maybe<const ast::Alias*> ParserImpl::type_alias_decl() {
Source source; Source source;
if (match(Token::Type::kAlias, &source)) { if (!match(Token::Type::kAlias, &source)) {
// matched.
} else if (match(Token::Type::kType, &source)) {
// TODO(crbug.com/tint/1812): DEPRECATED
deprecated(source, "'type' has been renamed to 'alias'");
} else {
return Failure::kNoMatch; return Failure::kNoMatch;
} }

View File

@ -52,14 +52,9 @@ fn f() { return 1 & >; }
} }
TEST_F(ParserImplErrorTest, AliasDeclInvalidAttribute) { TEST_F(ParserImplErrorTest, AliasDeclInvalidAttribute) {
EXPECT( EXPECT("@invariant alias e=u32;",
"@invariant type e=u32;", R"(test.wgsl:1:2 error: unexpected attributes
R"(test.wgsl:1:12 warning: use of deprecated language feature: 'type' has been renamed to 'alias' @invariant alias e=u32;
@invariant type e=u32;
^^^^
test.wgsl:1:2 error: unexpected attributes
@invariant type e=u32;
^^^^^^^^^ ^^^^^^^^^
)"); )");
} }
@ -681,10 +676,10 @@ const_assert;
} }
TEST_F(ParserImplErrorTest, GlobalDeclConstAssertMissingCondThenAlias) { TEST_F(ParserImplErrorTest, GlobalDeclConstAssertMissingCondThenAlias) {
EXPECT("const_assert\ntype T = i32;", EXPECT("const_assert\nalias T = i32;",
R"(test.wgsl:2:1 error: unable to parse condition expression R"(test.wgsl:2:1 error: unable to parse condition expression
type T = i32; alias T = i32;
^^^^ ^^^^^
)"); )");
} }
@ -736,14 +731,14 @@ static_assert;
// TODO(crbug.com/tint/1807): DEPRECATED // TODO(crbug.com/tint/1807): DEPRECATED
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingCondThenAlias) { TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingCondThenAlias) {
EXPECT( EXPECT(
"static_assert\ntype T = i32;", "static_assert\nalias T = i32;",
R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert'
static_assert static_assert
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
test.wgsl:2:1 error: unable to parse condition expression test.wgsl:2:1 error: unable to parse condition expression
type T = i32; alias T = i32;
^^^^ ^^^^^
)"); )");
} }
@ -882,57 +877,6 @@ alias meow = f32
)"); )");
} }
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclTypeAliasMissingIdentifier) {
EXPECT("alias 1 = f32;",
R"(test.wgsl:1:7 error: expected identifier for type alias
alias 1 = f32;
^
)");
}
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclTypeAliasInvalidType) {
EXPECT(
"type meow = 1;",
R"(test.wgsl:1:1 warning: use of deprecated language feature: 'type' has been renamed to 'alias'
type meow = 1;
^^^^
test.wgsl:1:13 error: invalid type alias
type meow = 1;
^
)");
}
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclTypeAliasMissingAssignment) {
EXPECT(
"type meow f32",
R"(test.wgsl:1:1 warning: use of deprecated language feature: 'type' has been renamed to 'alias'
type meow f32
^^^^
test.wgsl:1:11 error: expected '=' for type alias
type meow f32
^^^
)");
}
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclTypeAliasMissingSemicolon) {
EXPECT(
"type meow = f32",
R"(test.wgsl:1:1 warning: use of deprecated language feature: 'type' has been renamed to 'alias'
type meow = f32
^^^^
test.wgsl:1:16 error: expected ';' for type alias
type meow = f32
^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayMissingGreaterThan) { TEST_F(ParserImplErrorTest, GlobalDeclVarArrayMissingGreaterThan) {
EXPECT("var i : array<u32, 3;", EXPECT("var i : array<u32, 3;",
R"(test.wgsl:1:14 error: expected ';' for variable declaration R"(test.wgsl:1:14 error: expected ';' for variable declaration

View File

@ -132,41 +132,6 @@ alias B = A;)");
ast::CheckIdentifier(program.Symbols(), alias->type, "A"); ast::CheckIdentifier(program.Symbols(), alias->type, "A");
} }
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplTest, DEPRECATED_GlobalDecl_TypeAlias) {
auto p = parser("type A = i32;");
p->global_decl();
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
ASSERT_EQ(program.AST().TypeDecls().Length(), 1u);
ASSERT_TRUE(program.AST().TypeDecls()[0]->Is<ast::Alias>());
ast::CheckIdentifier(program.Symbols(), program.AST().TypeDecls()[0]->As<ast::Alias>()->name,
"A");
}
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplTest, DEPRECATED_GlobalDecl_TypeAlias_StructIdent) {
auto p = parser(R"(struct A {
a : f32,
}
type B = A;)");
p->global_decl();
p->global_decl();
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
ASSERT_EQ(program.AST().TypeDecls().Length(), 2u);
ASSERT_TRUE(program.AST().TypeDecls()[0]->Is<ast::Struct>());
auto* str = program.AST().TypeDecls()[0]->As<ast::Struct>();
EXPECT_EQ(str->name->symbol, program.Symbols().Get("A"));
ASSERT_TRUE(program.AST().TypeDecls()[1]->Is<ast::Alias>());
auto* alias = program.AST().TypeDecls()[1]->As<ast::Alias>();
EXPECT_EQ(alias->name->symbol, program.Symbols().Get("B"));
ast::CheckIdentifier(program.Symbols(), alias->type, "A");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) { TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) {
auto p = parser("alias A = i32"); auto p = parser("alias A = i32");
p->global_decl(); p->global_decl();
@ -174,16 +139,6 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) {
EXPECT_EQ(p->error(), "1:14: expected ';' for type alias"); EXPECT_EQ(p->error(), "1:14: expected ';' for type alias");
} }
// TODO(crbug.com/tint/1812): DEPRECATED
TEST_F(ParserImplTest, DEPRECATED_GlobalDecl_TypeAlias_MissingSemicolon) {
auto p = parser("type A = i32");
p->global_decl();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(),
R"(1:1: use of deprecated language feature: 'type' has been renamed to 'alias'
1:13: expected ';' for type alias)");
}
TEST_F(ParserImplTest, GlobalDecl_Function) { TEST_F(ParserImplTest, GlobalDecl_Function) {
auto p = parser("fn main() { return; }"); auto p = parser("fn main() { return; }");
p->global_decl(); p->global_decl();

View File

@ -216,6 +216,7 @@ INSTANTIATE_TEST_SUITE_P(ParserImplReservedKeywordTest,
"throw", "throw",
"trait", "trait",
"try", "try",
"type",
"typedef", "typedef",
"typeid", "typeid",
"typename", "typename",

View File

@ -19,7 +19,7 @@ namespace tint::reader::wgsl {
namespace { namespace {
TEST_F(ParserImplTest, TypeDecl_ParsesType) { TEST_F(ParserImplTest, TypeDecl_ParsesType) {
auto p = parser("type a = i32"); auto p = parser("alias a = i32");
auto t = p->type_alias_decl(); auto t = p->type_alias_decl();
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
@ -29,11 +29,11 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
ASSERT_TRUE(t->Is<ast::Alias>()); ASSERT_TRUE(t->Is<ast::Alias>());
auto* alias = t->As<ast::Alias>(); auto* alias = t->As<ast::Alias>();
ast::CheckIdentifier(p->builder().Symbols(), alias->type, "i32"); ast::CheckIdentifier(p->builder().Symbols(), alias->type, "i32");
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 13u}})); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 14u}}));
} }
TEST_F(ParserImplTest, TypeDecl_Parses_Ident) { TEST_F(ParserImplTest, TypeDecl_Parses_Ident) {
auto p = parser("type a = B"); auto p = parser("alias a = B");
auto t = p->type_alias_decl(); auto t = p->type_alias_decl();
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
@ -44,7 +44,7 @@ TEST_F(ParserImplTest, TypeDecl_Parses_Ident) {
auto* alias = t.value->As<ast::Alias>(); auto* alias = t.value->As<ast::Alias>();
ast::CheckIdentifier(p->builder().Symbols(), alias->name, "a"); ast::CheckIdentifier(p->builder().Symbols(), alias->name, "a");
ast::CheckIdentifier(p->builder().Symbols(), alias->type, "B"); ast::CheckIdentifier(p->builder().Symbols(), alias->type, "B");
EXPECT_EQ(alias->source.range, (Source::Range{{1u, 1u}, {1u, 11u}})); EXPECT_EQ(alias->source.range, (Source::Range{{1u, 1u}, {1u, 12u}}));
} }
TEST_F(ParserImplTest, TypeDecl_Unicode_Parses_Ident) { TEST_F(ParserImplTest, TypeDecl_Unicode_Parses_Ident) {
@ -52,7 +52,7 @@ TEST_F(ParserImplTest, TypeDecl_Unicode_Parses_Ident) {
"\xf0\x9d\x93\xb6\xf0\x9d\x94\x82\x5f\xf0\x9d\x93\xbd\xf0\x9d\x94\x82\xf0" "\xf0\x9d\x93\xb6\xf0\x9d\x94\x82\x5f\xf0\x9d\x93\xbd\xf0\x9d\x94\x82\xf0"
"\x9d\x93\xb9\xf0\x9d\x93\xae"; "\x9d\x93\xb9\xf0\x9d\x93\xae";
auto p = parser("type " + ident + " = i32"); auto p = parser("alias " + ident + " = i32");
auto t = p->type_alias_decl(); auto t = p->type_alias_decl();
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
@ -63,43 +63,37 @@ TEST_F(ParserImplTest, TypeDecl_Unicode_Parses_Ident) {
auto* alias = t.value->As<ast::Alias>(); auto* alias = t.value->As<ast::Alias>();
ast::CheckIdentifier(p->builder().Symbols(), alias->name, ident); ast::CheckIdentifier(p->builder().Symbols(), alias->name, ident);
ast::CheckIdentifier(p->builder().Symbols(), alias->type, "i32"); ast::CheckIdentifier(p->builder().Symbols(), alias->type, "i32");
EXPECT_EQ(alias->source.range, (Source::Range{{1u, 1u}, {1u, 37u}})); EXPECT_EQ(alias->source.range, (Source::Range{{1u, 1u}, {1u, 38u}}));
} }
TEST_F(ParserImplTest, TypeDecl_MissingIdent) { TEST_F(ParserImplTest, TypeDecl_MissingIdent) {
auto p = parser("type = i32"); auto p = parser("alias = i32");
auto t = p->type_alias_decl(); auto t = p->type_alias_decl();
EXPECT_TRUE(t.errored); EXPECT_TRUE(t.errored);
EXPECT_FALSE(t.matched); EXPECT_FALSE(t.matched);
EXPECT_TRUE(p->has_error()); EXPECT_TRUE(p->has_error());
EXPECT_EQ(t.value, nullptr); EXPECT_EQ(t.value, nullptr);
EXPECT_EQ(p->error(), EXPECT_EQ(p->error(), R"(1:7: expected identifier for type alias)");
R"(1:1: use of deprecated language feature: 'type' has been renamed to 'alias'
1:6: expected identifier for type alias)");
} }
TEST_F(ParserImplTest, TypeDecl_InvalidIdent) { TEST_F(ParserImplTest, TypeDecl_InvalidIdent) {
auto p = parser("type 123 = i32"); auto p = parser("alias 123 = i32");
auto t = p->type_alias_decl(); auto t = p->type_alias_decl();
EXPECT_TRUE(t.errored); EXPECT_TRUE(t.errored);
EXPECT_FALSE(t.matched); EXPECT_FALSE(t.matched);
EXPECT_TRUE(p->has_error()); EXPECT_TRUE(p->has_error());
EXPECT_EQ(t.value, nullptr); EXPECT_EQ(t.value, nullptr);
EXPECT_EQ(p->error(), EXPECT_EQ(p->error(), R"(1:7: expected identifier for type alias)");
R"(1:1: use of deprecated language feature: 'type' has been renamed to 'alias'
1:6: expected identifier for type alias)");
} }
TEST_F(ParserImplTest, TypeDecl_MissingEqual) { TEST_F(ParserImplTest, TypeDecl_MissingEqual) {
auto p = parser("type a i32"); auto p = parser("alias a i32");
auto t = p->type_alias_decl(); auto t = p->type_alias_decl();
EXPECT_TRUE(t.errored); EXPECT_TRUE(t.errored);
EXPECT_FALSE(t.matched); EXPECT_FALSE(t.matched);
EXPECT_TRUE(p->has_error()); EXPECT_TRUE(p->has_error());
EXPECT_EQ(t.value, nullptr); EXPECT_EQ(t.value, nullptr);
EXPECT_EQ(p->error(), EXPECT_EQ(p->error(), R"(1:9: expected '=' for type alias)");
R"(1:1: use of deprecated language feature: 'type' has been renamed to 'alias'
1:8: expected '=' for type alias)");
} }
} // namespace } // namespace

View File

@ -189,8 +189,6 @@ std::string_view Token::TypeToName(Type type) {
return "switch"; return "switch";
case Token::Type::kTrue: case Token::Type::kTrue:
return "true"; return "true";
case Token::Type::kType:
return "type";
case Token::Type::kVar: case Token::Type::kVar:
return "var"; return "var";
case Token::Type::kWhile: case Token::Type::kWhile:

View File

@ -201,8 +201,6 @@ class Token {
kSwitch, kSwitch,
/// A 'true' /// A 'true'
kTrue, kTrue,
/// A 'type'
kType,
/// A 'var' /// A 'var'
kVar, kVar,
/// A 'while' /// A 'while'

View File

@ -132,7 +132,7 @@ fn main() {
TEST_F(AddBlockAttributeTest, BasicArray_Alias) { TEST_F(AddBlockAttributeTest, BasicArray_Alias) {
auto* src = R"( auto* src = R"(
type Numbers = array<vec4<f32>, 4u>; alias Numbers = array<vec4<f32>, 4u>;
@group(0) @binding(0) @group(0) @binding(0)
var<uniform> u : Numbers; var<uniform> u : Numbers;
@ -693,13 +693,13 @@ struct Inner {
f : f32, f : f32,
}; };
type MyInner = Inner; alias MyInner = Inner;
struct Outer { struct Outer {
i : MyInner, i : MyInner,
}; };
type MyOuter = Outer; alias MyOuter = Outer;
@group(0) @binding(0) @group(0) @binding(0)
var<uniform> u0 : MyOuter; var<uniform> u0 : MyOuter;
@ -763,12 +763,12 @@ fn main() {
@group(0) @binding(1) @group(0) @binding(1)
var<uniform> u1 : MyInner; var<uniform> u1 : MyInner;
type MyInner = Inner; alias MyInner = Inner;
@group(0) @binding(0) @group(0) @binding(0)
var<uniform> u0 : MyOuter; var<uniform> u0 : MyOuter;
type MyOuter = Outer; alias MyOuter = Outer;
struct Outer { struct Outer {
i : MyInner, i : MyInner,

View File

@ -164,7 +164,7 @@ fn frag_main(tint_symbol : tint_symbol_1) {
TEST_F(CanonicalizeEntryPointIOTest, Parameter_TypeAlias) { TEST_F(CanonicalizeEntryPointIOTest, Parameter_TypeAlias) {
auto* src = R"( auto* src = R"(
type myf32 = f32; alias myf32 = f32;
@fragment @fragment
fn frag_main(@location(1) loc1 : myf32) { fn frag_main(@location(1) loc1 : myf32) {
@ -204,7 +204,7 @@ fn frag_main(@location(1) loc1 : myf32) {
var x : myf32 = loc1; var x : myf32 = loc1;
} }
type myf32 = f32; alias myf32 = f32;
)"; )";
auto* expect = R"( auto* expect = R"(
@ -1561,7 +1561,7 @@ struct FragmentInput {
TEST_F(CanonicalizeEntryPointIOTest, Struct_TypeAliases) { TEST_F(CanonicalizeEntryPointIOTest, Struct_TypeAliases) {
auto* src = R"( auto* src = R"(
type myf32 = f32; alias myf32 = f32;
struct FragmentInput { struct FragmentInput {
@location(0) col1 : myf32, @location(0) col1 : myf32,
@ -1573,9 +1573,9 @@ struct FragmentOutput {
@location(1) col2 : myf32, @location(1) col2 : myf32,
}; };
type MyFragmentInput = FragmentInput; alias MyFragmentInput = FragmentInput;
type MyFragmentOutput = FragmentOutput; alias MyFragmentOutput = FragmentOutput;
fn foo(x : MyFragmentInput) -> myf32 { fn foo(x : MyFragmentInput) -> myf32 {
return x.col1; return x.col1;
@ -1653,9 +1653,9 @@ fn frag_main(inputs : MyFragmentInput) -> MyFragmentOutput {
return MyFragmentOutput(x, inputs.col2); return MyFragmentOutput(x, inputs.col2);
} }
type MyFragmentInput = FragmentInput; alias MyFragmentInput = FragmentInput;
type MyFragmentOutput = FragmentOutput; alias MyFragmentOutput = FragmentOutput;
fn foo(x : MyFragmentInput) -> myf32 { fn foo(x : MyFragmentInput) -> myf32 {
return x.col1; return x.col1;
@ -1671,7 +1671,7 @@ struct FragmentOutput {
@location(1) col2 : myf32, @location(1) col2 : myf32,
}; };
type myf32 = f32; alias myf32 = f32;
)"; )";
auto* expect = R"( auto* expect = R"(

View File

@ -232,7 +232,7 @@ fn main() -> vec4<f32> {
TEST_F(CombineSamplersTest, AliasedTypes) { TEST_F(CombineSamplersTest, AliasedTypes) {
auto* src = R"( auto* src = R"(
type Tex2d = texture_2d<f32>; alias Tex2d = texture_2d<f32>;
@group(0) @binding(0) var t : Tex2d; @group(0) @binding(0) var t : Tex2d;
@ -282,7 +282,7 @@ fn sample(t : Tex2d, s : sampler, coords : vec2<f32>) -> vec4<f32> {
@group(0) @binding(0) var t : Tex2d; @group(0) @binding(0) var t : Tex2d;
@group(0) @binding(1) var s : sampler; @group(0) @binding(1) var s : sampler;
type Tex2d = texture_2d<f32>; alias Tex2d = texture_2d<f32>;
)"; )";
auto* expect = R"( auto* expect = R"(
@group(0) @binding(0) @internal(disable_validation__binding_point_collision) var t_s : texture_2d<f32>; @group(0) @binding(0) @internal(disable_validation__binding_point_collision) var t_s : texture_2d<f32>;

View File

@ -3401,9 +3401,9 @@ struct S1 {
c : i32, c : i32,
}; };
type A1 = S1; alias A1 = S1;
type A1_Array = array<S1, 3>; alias A1_Array = array<S1, 3>;
struct S2 { struct S2 {
a : i32, a : i32,
@ -3411,9 +3411,9 @@ struct S2 {
c : i32, c : i32,
}; };
type A2 = S2; alias A2 = S2;
type A2_Array = array<S2>; alias A2_Array = array<S2>;
struct SB { struct SB {
@size(128) @size(128)
@ -3496,9 +3496,9 @@ struct SB {
b : A2_Array, b : A2_Array,
}; };
type A2_Array = array<S2>; alias A2_Array = array<S2>;
type A2 = S2; alias A2 = S2;
struct S2 { struct S2 {
a : i32, a : i32,
@ -3506,9 +3506,9 @@ struct S2 {
c : i32, c : i32,
}; };
type A1 = S1; alias A1 = S1;
type A1_Array = array<S1, 3>; alias A1_Array = array<S1, 3>;
struct S1 { struct S1 {
a : i32, a : i32,

View File

@ -818,7 +818,7 @@ struct Inner {
mat : mat3x4<f32>, mat : mat3x4<f32>,
}; };
type InnerArr = array<Inner, 4>; alias InnerArr = array<Inner, 4>;
struct Outer { struct Outer {
arr : InnerArr, arr : InnerArr,
@ -1112,7 +1112,7 @@ struct Inner {
mat : mat3x4<f32>, mat : mat3x4<f32>,
}; };
type InnerArr = array<Inner, 4>; alias InnerArr = array<Inner, 4>;
struct Outer { struct Outer {
arr : InnerArr, arr : InnerArr,
@ -1356,7 +1356,7 @@ struct Inner {
mat : mat3x4<f32>, mat : mat3x4<f32>,
}; };
type InnerArr = array<Inner, 4>; alias InnerArr = array<Inner, 4>;
struct Outer { struct Outer {
arr : InnerArr, arr : InnerArr,
@ -1828,7 +1828,7 @@ struct Inner {
mat : mat3x4<f32>, mat : mat3x4<f32>,
}; };
type InnerArr = array<Inner, 4>; alias InnerArr = array<Inner, 4>;
struct Outer { struct Outer {
arr : InnerArr, arr : InnerArr,

View File

@ -605,7 +605,7 @@ fn foo(@internal(disable_validation__ignore_address_space) @internal(disable_val
TEST_F(ModuleScopeVarToEntryPointParamTest, Buffer_RuntimeArray_Alias) { TEST_F(ModuleScopeVarToEntryPointParamTest, Buffer_RuntimeArray_Alias) {
auto* src = R"( auto* src = R"(
type myarray = array<f32>; alias myarray = array<f32>;
@group(0) @binding(0) @group(0) @binding(0)
var<storage> buffer : myarray; var<storage> buffer : myarray;
@ -643,7 +643,7 @@ fn main() {
@group(0) @binding(0) var<storage> buffer : myarray; @group(0) @binding(0) var<storage> buffer : myarray;
type myarray = array<f32>; alias myarray = array<f32>;
)"; )";
auto* expect = R"( auto* expect = R"(

View File

@ -32,7 +32,7 @@ TEST_F(MultiplanarExternalTextureTest, ShouldRunEmptyModule) {
TEST_F(MultiplanarExternalTextureTest, ShouldRunHasExternalTextureAlias) { TEST_F(MultiplanarExternalTextureTest, ShouldRunHasExternalTextureAlias) {
auto* src = R"( auto* src = R"(
type ET = texture_external; alias ET = texture_external;
)"; )";
DataMap data; DataMap data;
@ -1616,7 +1616,7 @@ fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_param
// Tests that the the transform handles aliases to external textures // Tests that the the transform handles aliases to external textures
TEST_F(MultiplanarExternalTextureTest, ExternalTextureAlias) { TEST_F(MultiplanarExternalTextureTest, ExternalTextureAlias) {
auto* src = R"( auto* src = R"(
type ET = texture_external; alias ET = texture_external;
fn f(t : ET, s : sampler) { fn f(t : ET, s : sampler) {
textureSampleBaseClampToEdge(t, s, vec2<f32>(1.0, 2.0)); textureSampleBaseClampToEdge(t, s, vec2<f32>(1.0, 2.0));
@ -1724,7 +1724,7 @@ fn f(t : ET, s : sampler) {
@group(0) @binding(0) var ext_tex : ET; @group(0) @binding(0) var ext_tex : ET;
@group(0) @binding(1) var smp : sampler; @group(0) @binding(1) var smp : sampler;
type ET = texture_external; alias ET = texture_external;
)"; )";
auto* expect = R"( auto* expect = R"(

View File

@ -373,7 +373,7 @@ fn foo() {
TEST_F(PreservePaddingTest, ArrayOfArray) { TEST_F(PreservePaddingTest, ArrayOfArray) {
auto* src = R"( auto* src = R"(
type Array = array<array<vec3<u32>, 4>, 3>; alias Array = array<array<vec3<u32>, 4>, 3>;
@group(0) @binding(0) var<storage, read_write> v : Array; @group(0) @binding(0) var<storage, read_write> v : Array;

View File

@ -1856,7 +1856,7 @@ TEST_P(RenamerBuiltinTypeTest, RenameShadowedByAlias) {
}; };
auto src = expand(R"( auto src = expand(R"(
type $name = $other_type; alias $name = $other_type;
@fragment @fragment
fn f() { fn f() {

View File

@ -416,7 +416,7 @@ TEST_F(SingleEntryPointTest, OverridableConstants_UnusedAliasForOverrideSizedArr
// This is all unused by the target entry point. // This is all unused by the target entry point.
@id(1) override c1 : u32; @id(1) override c1 : u32;
type arr_ty = array<i32, c1>; alias arr_ty = array<i32, c1>;
var<workgroup> arr : arr_ty; var<workgroup> arr : arr_ty;
@compute @workgroup_size(64) @compute @workgroup_size(64)

View File

@ -210,13 +210,13 @@ fn f() {
TEST_F(SpirvAtomicTest, AliasedArraysOfU32) { TEST_F(SpirvAtomicTest, AliasedArraysOfU32) {
auto* src = R"( auto* src = R"(
type A0 = u32; alias A0 = u32;
type A1 = array<A0, 1>; alias A1 = array<A0, 1>;
type A2 = array<A1, 2>; alias A2 = array<A1, 2>;
type A3 = array<A2, 3>; alias A3 = array<A2, 3>;
var<workgroup> wg : A3; var<workgroup> wg : A3;

View File

@ -50,7 +50,7 @@ fn F(c : i32) {
TEST_F(UnshadowTest, LocalShadowsAlias) { TEST_F(UnshadowTest, LocalShadowsAlias) {
auto* src = R"( auto* src = R"(
type a = i32; alias a = i32;
fn X() { fn X() {
var a = false; var a = false;
@ -100,7 +100,7 @@ fn Z() {
const a = true; const a = true;
} }
type a = i32; alias a = i32;
)"; )";
auto* expect = R"( auto* expect = R"(
@ -691,7 +691,7 @@ const a : i32 = 1;
TEST_F(UnshadowTest, ParamShadowsAlias) { TEST_F(UnshadowTest, ParamShadowsAlias) {
auto* src = R"( auto* src = R"(
type a = i32; alias a = i32;
fn F(a : a) { fn F(a : a) {
{ {
@ -732,7 +732,7 @@ fn F(a : a) {
} }
} }
type a = i32; alias a = i32;
)"; )";
auto* expect = R"( auto* expect = R"(

View File

@ -1366,7 +1366,7 @@ struct S {
TEST_F(ZeroInitWorkgroupMemoryTest, ArrayWithOverrideCount) { TEST_F(ZeroInitWorkgroupMemoryTest, ArrayWithOverrideCount) {
auto* src = auto* src =
R"(override O = 123; R"(override O = 123;
type A = array<i32, O*2>; alias A = array<i32, O*2>;
var<workgroup> W : A; var<workgroup> W : A;