[Issue 3444] foreach(i, elem; range) should work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 15 13:10:23 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=3444

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |simen.kjaras at gmail.com
         Resolution|FIXED                       |---

--- Comment #5 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Really? Cause this fails to compile for me:

unittest {
    import std.range, std.stdio;
    foreach (i, e; 100.iota)
        writeln(i, ": ", e);
}

Error: cannot infer argument types, expected 1 argument, not 2

Adding types for i and e, or using ranges other than iota, don't seem to change
the result. This is on DMD 2.078.2 on Windows.

There's a workaround in std.range.enumerate. If that's the implementation you
refer to, please include that information. If there's an implementation of this
in an upcoming DMD release, please include that information.

--


More information about the Digitalmars-d-bugs mailing list