Bug 7948 – std.range.zip broken with requireSameLength
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-20T07:02:00Z
Last change time
2012-07-01T18:32:45Z
Assigned to
nobody
Creator
jens.k.mueller
Comments
Comment #0 by jens.k.mueller — 2012-04-20T07:02:16Z
unittest
{
import std.algorithm;
import std.range;
int[] a = [ 1, 2, 3 ];
string[] b = [ "a", "b", "c" ];
sort!("a[0] > b[0]")(zip(StoppingPolicy.requireSameLength, a, b));
assert(a == [ 3, 2, 1 ]);
assert(b == [ "c", "b", "a" ]);
}
fails with
phobos/std/range.d(3563): Invalid Zip object
but is expected to pass (the provided ranges have the same length). The checking code in range.d is wrong.
Comment #1 by lovelydear — 2012-04-21T13:18:33Z
For convenience, same code as above:
import std.algorithm;
import std.range;
void main(){
int[] a = [ 1, 2, 3 ];
string[] b = [ "a", "b", "c" ];
sort!("a[0] > b[0]")(zip(StoppingPolicy.requireSameLength, a, b));
assert(a == [ 3, 2, 1 ]);
assert(b == [ "c", "b", "a" ]);
}
Comment #2 by github-bugzilla — 2012-07-01T18:29:54Z