[ir] Use inference for array of builtin structs These structures are unnameable in WGSL, so we cannot use an explicit element type when converting IR to AST. Fixed: 353249345 Change-Id: I4cd2218a52839864ac9042f61df167dbdac2194d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/199777 Auto-Submit: James Price <jrprice@google.com> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: David Neto <dneto@google.com>
diff --git a/src/tint/lang/wgsl/ir_roundtrip_test.cc b/src/tint/lang/wgsl/ir_roundtrip_test.cc index 278e8a6..4d8d5cd 100644 --- a/src/tint/lang/wgsl/ir_roundtrip_test.cc +++ b/src/tint/lang/wgsl/ir_roundtrip_test.cc
@@ -3391,5 +3391,15 @@ )"); } +// Test that we do not try to name the unnameable builtin structure types in array declarations. +// See crbug.com/353249345. +TEST_F(IRToProgramRoundtripTest, BuiltinStructInInferredArrayType) { + RUN_TEST(R"( +fn a(x : f32) { + let y = array(frexp(x)); +} +)"); +} + } // namespace } // namespace tint::wgsl
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc index 265b787..f932f2e 100644 --- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc +++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
@@ -953,6 +953,11 @@ }, [&](const core::type::Array* a) { auto el = Type(a->ElemType()); + if (!el) { + // The element type is untypeable, so we need to infer it instead. + return ast::Type{b.Expr(b.Ident("array"))}; + } + Vector<const ast::Attribute*, 1> attrs; if (!a->IsStrideImplicit()) { attrs.Push(b.Stride(a->Stride()));