[Issue 16521] Wrong code generation with switch + static foreach

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 30 05:37:30 PST 2017


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

Nemanja Boric <4burgos at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |4burgos at gmail.com

--- Comment #2 from Nemanja Boric <4burgos at gmail.com> ---
I hit the same bug today:

```
import std.traits;

struct S
{
    int a, b, c, d, e, f;
}

void main()
{
    S s;

    foreach (name; ["a", "b", "c"])
    {
        switch (name)
        {
            foreach (i, ref field; s.tupleof)
            {
                case __traits(identifier, S.tupleof[i]):
                    field = 0; // s.tupleof[i] = 0; works
                    break;
            }
            default:
                break;
        }
    }
}
```

--


More information about the Digitalmars-d-bugs mailing list