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: [email protected]
Reporter: [email protected]
----------------------
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
----------------------
--