[Issue 17041] New: foreach-ref can't use to static array's AliasSeq

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Dec 28 23:55:13 PST 2016


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

          Issue ID: 17041
           Summary: foreach-ref can't use to static array's AliasSeq
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: moskou.moskou at gmail.com

----------------------
import std.stdio, std.meta;

int main(string[] argv) {
    int x, y, z;
    foreach (ref v; AliasSeq!(x, y, z)) {
        v = 1;
    }
    writeln(x, ",", y, ",", z); //1,1,1
    int[2] a, b, c;
    foreach (ref v; AliasSeq!(a, b, c)) { //compile error!
        v[0] = 1;
    }
    writeln(a, ",", b, ",", c);
    return 0;
}
----------------------

This code can't compile with dmd(v2.072.2-b1).

Output Message
----------------------
bash-3.2$ dmd A.d
A.d(10): Error: symbol foreach (ref v; tuple(a, b, c))
{
v[0] = 1;
}
 cannot be ref
----------------------

--


More information about the Digitalmars-d-bugs mailing list