AliasAssign - is this a bug?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Apr 28 00:29:46 UTC 2021


Here's an example reduced from a more complex use case:

import std.meta : AliasSeq, staticMap;
template AliasThisType(T) {
     alias A = AliasSeq!();
     static foreach (U; AliasSeq!(__traits(getMember, T, "xyz"))) {
         alias A = AliasSeq!(A, typeof(U));
     }
     alias AliasThisType = A;
}

struct HasNoAliasThis {
}

struct HasAliasThis {
     HasNoAliasThis xyz;
     alias xyz this;
}

alias X = AliasThisType!HasAliasThis;

This should work, shouldn't it? When trying to compile I get:

test.d(7): Error: alias 
`test.AliasThisType!(HasAliasThis).__anonymous.A` conflicts with alias 
`test.AliasThisType!(HasAliasThis).A` at test.d(4)
HasNoAliasThis
test.d(20): Error: template instance `test.AliasThisType!(HasAliasThis)` 
error instantiating

Is this a bug? If not, where is the mistake in the code? If so, what 
would be a workaround? Thanks!


More information about the Digitalmars-d mailing list