Bug 17091 – std.range.zip cannot "save" correctly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-01-15T17:30:00Z
Last change time
2017-01-16T11:05:51Z
Assigned to
nobody
Creator
enjouzensyou.boinc

Comments

Comment #0 by enjouzensyou.boinc — 2017-01-15T17:30:36Z
Following code cannot be done correctly. I tested the following code on DMDv2.072.2. The line of the 4th `writeln` should output "[Tuple!(int, int)(1, 4), Tuple!(int, int)(2, 5), Tuple!(int, int)(3, 6)]". ---- import std.range; import std.algorithm; import std.stdio; void main() { auto s1 = [1, 2, 3].inputRangeObject; auto s2 = [4, 5, 6].inputRangeObject; writeln(s1.save); // [1, 2, 3], OK writeln(s2.save); // [1, 2, 3], OK auto added = s1.zip(s2); writeln(zs.save); // [Tuple!(int, int)(1, 4), Tuple!(int, int)(2, 5), Tuple!(int, int)(3, 6)], OK writeln(zs.save); // [], NG } ----
Comment #1 by enjouzensyou.boinc — 2017-01-15T17:33:02Z
(In reply to Kazuki Komatsu from comment #0) > Following code cannot be done correctly. > I tested the following code on DMDv2.072.2. > The line of the 4th `writeln` should output "[Tuple!(int, int)(1, 4), > Tuple!(int, int)(2, 5), Tuple!(int, int)(3, 6)]". > > ---- > import std.range; > import std.algorithm; > import std.stdio; > > void main() > { > auto s1 = [1, 2, 3].inputRangeObject; > auto s2 = [4, 5, 6].inputRangeObject; > > writeln(s1.save); // [1, 2, 3], OK > writeln(s2.save); // [1, 2, 3], OK > > auto added = s1.zip(s2); > writeln(zs.save); // [Tuple!(int, int)(1, 4), Tuple!(int, int)(2, 5), > Tuple!(int, int)(3, 6)], OK > writeln(zs.save); // [], NG > } > ---- Sorry, `auto added = s1.zip(s2);` is wrong. The correct code is following one -------- import std.range; import std.algorithm; import std.stdio; void main() { auto s1 = [1, 2, 3].inputRangeObject; auto s2 = [4, 5, 6].inputRangeObject; writeln(s1.save); // [1, 2, 3], OK writeln(s2.save); // [1, 2, 3], OK auto zs = s1.zip(s2); writeln(zs.save); // [Tuple!(int, int)(1, 4), Tuple!(int, int)(2, 5), Tuple!(int, int)(3, 6)], OK writeln(zs.save); // [], NG } --------
Comment #2 by electrolysis.jp+d — 2017-01-16T09:31:08Z
Comment #3 by enjouzensyou.boinc — 2017-01-16T11:04:04Z
Thank you, and Sorry.