[Issue 8061] std.algorithm.joiner breaks when used with InputRangeObject
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 19 22:34:43 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8061
--- Comment #5 from hsteoh at quickfur.ath.cx 2012-12-19 22:34:41 PST ---
Found cause of problem: in std.format.formatRange(), there's a static if block
that reads:
... else static if (isForwardRange!T && !isInfinite!T)
auto len = walkLength(val.save);
If this line is artificially modified to set len to some fixed value (say, the
length of the joined string), then the OP's code works.
This implies that val.save did not *really* save the range; it returned a copy
that, when consumed, also consumes the original range.
Digging deeper into the joiner code, the criteria for the joined range to be a
forward range is if the range of ranges passed to joiner is both itself a
forward range, and its subranges are also forward ranges. In theory, if these
two conditions were really true, then the joined range should be a valid
forward range. So this indicates that the problem lies with the array of
InputRangeObjects passed to joiner.
And here we discover the root of the problem: std.array.save, which defines
.save for built-in arrays, always just returns the array, whereas the correct
implementation would be to call .save on all array elements (if they are
forward ranges).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list