Bug 6366 – alias this doesn't work with foreach range.front
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-23T05:24:00Z
Last change time
2011-08-25T20:33:15Z
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2011-07-23T05:24:39Z
This is similar bug2781, but different.
If range.front is alias this tuple (like std.typecons.Tuple), foreach statement does not expand it automatically.
Example:
auto r = zip(sequence!"n", "hello");
// typeof(r.front) == Tuple!(int, char)
foreach (i, ch; r)
{
if (i == 0) assert(ch == 'h');
if (i == 1) assert(ch == 'e');
if (i == 2) assert(ch == 'l');
if (i == 3) assert(ch == 'l');
if (i == 4) assert(ch == 'o');
}
Comment #1 by bearophile_hugs — 2011-07-23T05:34:02Z