diff --git a/src/tint/ast/matrix.cc b/src/tint/ast/matrix.cc index b9baa27693..8ad2b8a394 100644 --- a/src/tint/ast/matrix.cc +++ b/src/tint/ast/matrix.cc @@ -39,8 +39,10 @@ Matrix::~Matrix() = default; std::string Matrix::FriendlyName(const SymbolTable& symbols) const { std::ostringstream out; - out << "mat" << columns << "x" << rows << "<" << type->FriendlyName(symbols) - << ">"; + out << "mat" << columns << "x" << rows; + if (type) { + out << "<" << type->FriendlyName(symbols) << ">"; + } return out.str(); } diff --git a/src/tint/ast/matrix_test.cc b/src/tint/ast/matrix_test.cc index 54c11eb29d..216408fbaa 100644 --- a/src/tint/ast/matrix_test.cc +++ b/src/tint/ast/matrix_test.cc @@ -46,5 +46,10 @@ TEST_F(AstMatrixTest, FriendlyName) { EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3"); } +TEST_F(AstMatrixTest, FriendlyName_WithoutType) { + auto* m = create(nullptr, 3, 2); + EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3"); +} + } // namespace } // namespace tint::ast