diff --git a/stdlib/public/core/SIMDVectorTypes.swift.gyb b/stdlib/public/core/SIMDVectorTypes.swift.gyb index b5d91cecf7852..d079d77494fa7 100644 --- a/stdlib/public/core/SIMDVectorTypes.swift.gyb +++ b/stdlib/public/core/SIMDVectorTypes.swift.gyb @@ -109,6 +109,14 @@ public extension SIMD${n} where Scalar : FixedWidthInteger { } } +extension SIMD${n} : CustomDebugStringConvertible { + /// Debug string representation + public var debugDescription: String { + return "SIMD${n}<\(Scalar.self)>(${', '.join(map(lambda c: + '\\(self['+ str(c) + '])', + xrange(n)))})" + } +} public extension SIMD${n} where Scalar : BinaryFloatingPoint { @inlinable diff --git a/test/stdlib/simd.swift.gyb b/test/stdlib/simd.swift.gyb index afadc168a5286..84bedf3570631 100644 --- a/test/stdlib/simd.swift.gyb +++ b/test/stdlib/simd.swift.gyb @@ -313,5 +313,10 @@ simdTestSuite.test("matrix elements") { % end # for type } +simdTestSuite.test("debug description") { + expectEqual("SIMD2(1.0, 2.5)", + SIMD2(1.0, 2.5).debugDescription) +} + runAllTests()