[Issue 9570] Wrong foreach index implicit conversion error

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 21 13:19:27 PDT 2014


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

--- Comment #5 from Lionello Lunesu <lio+bugzilla at lunesu.com> ---
(In reply to bearophile_hugs from comment #4)
> (In reply to Lionello Lunesu from comment #3)
> > https://github.com/D-Programming-Language/dmd/pull/3567
> 
> Is this supported?
> 
> void main() {
>     ubyte[256] data;
>     foreach (ubyte i, ref x; data)
>         x = i;
> }

No, the key must be declared const or immutable. Otherwise we need flow
analysis to ensure the key doesn't get mutated in the scope.

--


More information about the Digitalmars-d-bugs mailing list