Array.description uses Element.debugDescription?

Trying out another type, added Collection semantics. Doing another test by converting to Array and printing result. Something weird happened for my array-of-array.

let sa: SegmentedArray<Double> = [1, 2, 3, 4, 5]
let saa: SegmentedArray<SegmentedArray<Double>> = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 23, 13, 14, 15]]
let se: SegmentedArray<Double> = []
print(se, String(reflecting: se), se.debuggingOutput(goingDeep: true))
print(se.isEmpty, sa.isEmpty, saa.isEmpty)
print(Array(se), Array(sa), Array(saa))

Gave results:

[] [] []
true false false
[] [1.0, 2.0, 3.0, 4.0, 5.0] [[1.0, 2.0; 3.0, 4.0; 5.0 (1 element(s) reserved) (1 block(s) reserved)], [6.0, 7.0; 8.0, 9.0; 10.0 (1 element(s) reserved) (1 block(s) reserved)], [11.0, 23.0; 13.0, 14.0; 15.0 (1 element(s) reserved) (1 block(s) reserved)]]

(The block size is set to 2 here.)

For “Array(saa),” the inner custom array type isn’t stripped out. It seems that Array calls String(reflecting:) on its elements, instead of String(describing:). This seems that this surprise should be documented somewhere (or it’s a bug).

That’s intentional, because otherwise an array of strings would print its elements unquoted, which could lead to confusing output. ["a, b", "c, d"] would print as [a, b, c, d] for instance. Collections in general do not implement CustomStringConvertible but only CustomDebugStringConvertible due to the lack of a general non-parsable alternative printing.