Bug 17041 – foreach-ref can't use to static array's AliasSeq

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2016-12-29T07:55:13Z
Last change time
2021-06-04T05:33:37Z
Keywords
pull
Assigned to
No Owner
Creator
Kohei Morita

Comments

Comment #0 by moskou.moskou — 2016-12-29T07:55:13Z
---------------------- 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 ----------------------
Comment #1 by dlang-bot — 2021-06-03T11:35:23Z
@dkorpel created dlang/dmd pull request #12628 "Fix issue 17041 - foreach ref fails with static array in sequence" fixing this issue: - fix issue 17041 - foreach ref fails with static array sequence https://github.com/dlang/dmd/pull/12628
Comment #2 by dlang-bot — 2021-06-04T05:33:37Z
dlang/dmd pull request #12628 "Fix issue 17041 - foreach ref fails with static array in sequence" was merged into master: - dab6cb26f4c8f36a31ca80170953fa3e50b4c91a by dkorpel: fix issue 17041 - foreach ref fails with ValueSeq containing static array https://github.com/dlang/dmd/pull/12628