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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 8 08:24:34 UTC 2022


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #7 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Simen Kjaeraas from comment #5)
> 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.

I was referring to the enumarate workaround. Sorry for not being explicit.

As Dmitri has pointed out, the additional complexities added to support this
aren't worth it since we have a decent workaround.

--


More information about the Digitalmars-d-bugs mailing list