Skip to content

Commit fbf4bb7

Browse files
committed
[SIMD] Add CustomDebugStringConvertible conformance for SIMD types.
The old SIMD types had a conformance to CustomDebugStringConvertible, but the new ones do not, causing a source compatibility regression. Add back a CustomDebugStringConvertible conformance. Fixes rdar://problem/46746829.
1 parent b88a875 commit fbf4bb7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

stdlib/public/core/SIMDVectorTypes.swift.gyb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public extension SIMD${n} where Scalar : FixedWidthInteger {
109109
}
110110
}
111111

112+
extension SIMD${n} : CustomDebugStringConvertible {
113+
/// Debug string representation
114+
public var debugDescription: String {
115+
return "SIMD${n}<\(Scalar.self)>(${', '.join(map(lambda c:
116+
'\\(self['+ str(c) + '])',
117+
xrange(n)))})"
118+
}
119+
}
112120

113121
public extension SIMD${n} where Scalar : BinaryFloatingPoint {
114122
@inlinable

test/stdlib/simd.swift.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,10 @@ simdTestSuite.test("matrix elements") {
313313
% end # for type
314314
}
315315

316+
simdTestSuite.test("debug description") {
317+
expectEqual("SIMD2<Float>(1.0, 2.5)",
318+
SIMD2<Float>(1.0, 2.5).debugDescription)
319+
}
320+
316321
runAllTests()
317322

0 commit comments

Comments
 (0)