On Saturday, 18 July 2020 at 22:49:18 UTC, Dennis wrote:
On Saturday, 18 July 2020 at 18:46:16 UTC, Carl Sturtivant wrote:
Is there any way to avoid the duplication of the entries in the anonymous union, aside from using a mixin template?

I think this would be fixed if https://github.com/dlang/dmd/pull/11273 gets merged.

The feature still needs some work. With this PR aliases of members only works when they are declared in a function scope and not in the aggregate scope.

Example:

---
struct Inner
{
    int a;
}

struct TopLevel
{
    Inner inner;
    alias ia = inner.a;
}

void main()
{
    TopLevel tl;
    alias ia = tl.inner.a;
    ia = 42;        // OK with PR 11273
    tl.ia = 42;     // NG Error: need `this` for `a` of type `int`
}
---

I think it's not good to merge until the second case works.
Also it requires approval. For now it is specified that expressions cant be aliased.

Reply via email to