tint/writer/wgsl: Emit inferred-type arrays

Bug: tint:1628
Change-Id: If0907ee7c4dc3d0216aba0282dc2c5203a3ea727
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97590
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc
index 6ca7083..f3129c0 100644
--- a/src/tint/writer/wgsl/generator_impl.cc
+++ b/src/tint/writer/wgsl/generator_impl.cc
@@ -382,19 +382,22 @@
                 }
             }
 
-            out << "array<";
-            if (!EmitType(out, ary->type)) {
-                return false;
-            }
+            out << "array";
+            if (ary->type) {
+                out << "<";
+                TINT_DEFER(out << ">");
 
-            if (!ary->IsRuntimeArray()) {
-                out << ", ";
-                if (!EmitExpression(out, ary->count)) {
+                if (!EmitType(out, ary->type)) {
                     return false;
                 }
-            }
 
-            out << ">";
+                if (!ary->IsRuntimeArray()) {
+                    out << ", ";
+                    if (!EmitExpression(out, ary->count)) {
+                        return false;
+                    }
+                }
+            }
             return true;
         },
         [&](const ast::Bool*) {
diff --git a/src/tint/writer/wgsl/generator_impl_constructor_test.cc b/src/tint/writer/wgsl/generator_impl_constructor_test.cc
index 07b10ad..40bf393 100644
--- a/src/tint/writer/wgsl/generator_impl_constructor_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_constructor_test.cc
@@ -174,5 +174,17 @@
                           "vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f))"));
 }
 
+TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_ImplicitArray) {
+    WrapInFunction(Construct(ty.array(nullptr, nullptr), vec3<f32>(1_f, 2_f, 3_f),
+                             vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
+
+    GeneratorImpl& gen = Build();
+
+    ASSERT_TRUE(gen.Generate()) << gen.error();
+    EXPECT_THAT(gen.result(),
+                HasSubstr("array(vec3<f32>(1.0f, 2.0f, 3.0f), "
+                          "vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f))"));
+}
+
 }  // namespace
 }  // namespace tint::writer::wgsl