alias restriction??!

Basile B. b2.temp at
Sun Jul 19 04:53:53 UTC 2020

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 
> 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.


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.

More information about the Digitalmars-d-learn mailing list