Bug with writeln?
Saurabh Das
saurabh.das at gmail.com
Thu Sep 6 08:40:08 UTC 2018
Is this a bug with writeln?
void main()
{
import std.stdio, std.range, std.algorithm;
auto a1 = sort([1,3,5,4,2]);
auto a2 = sort([9,8,9]);
auto a3 = sort([5,4,5,4]);
pragma(msg, typeof(a1));
pragma(msg, typeof(a2));
pragma(msg, typeof(a3));
auto b = [a1, a2, a3];
pragma(msg, typeof(b));
writeln("b:");
writeln(b);
writeln(b); // <-- this one prints incorrectly
writeln("a:");
writeln(a1);
writeln(a2);
writeln(a3);
}
Output
======
SortedRange!(int[], "a < b")
SortedRange!(int[], "a < b")
SortedRange!(int[], "a < b")
SortedRange!(int[], "a < b")[]
b:
[[1, 2, 3, 4, 5], [8, 9, 9], [4, 4, 5, 5]]
[[], [], []]
a:
[1, 2, 3, 4, 5]
[8, 9, 9]
[4, 4, 5, 5]
The issue goes away if I cast 'b' to const before writeln. I
think it is a bug, but maybe I am missing something?
More information about the Digitalmars-d-learn
mailing list