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

Steven Schveighoffer <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #4 from Steven Schveighoffer <[email protected]> ---
Just helping out someone in discord, and ran into what looks like the same
issue.

What seems to happen is if the non-first union member is a static array, and
that array is set via indexing items, then it does not set the internal tag for
the union during CTFE, so it doesn't think the second member is set, and
instead writes out the first member.

Change option B to:

```d
v = v.init;
v[0] = x_;
v[1] = y_;
``` 

and it works. What I think happens is the assignment to v sets the union tag.

If you set v all at once, it also works:

```d
v = [x_, y_];
```

I think the compiler should detect the initialization via the indexed usage and
set the tag properly.

--

Reply via email to