You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Partial!()
/usr/local/include/dmd/std/traits.d(508): Error: alias `std.traits.moduleName!(Partial!()).moduleName` recursive alias declaration
alias moduleName = moduleName!(parentOf!T); // If you use enum, it will cause compiler ICE
^
test.d(17): Error: template instance `std.traits.moduleName!(Partial!())` error instantiating
pragma(msg, moduleName!(Partial!()));
^
test.d(17): while evaluating `pragma(msg, moduleName!(Partial!()))`
pragma(msg, moduleName!(Partial!()));
^
parentOf is a private trait in std.traits which is a wrapper around __traits(parent, ...). So, the line that's failing is basically
alias moduleName = moduleName!(__traits(parent, T));
and as the pragma(msg, ...) line shows, the parent of Partial!() is apparently itself. So, when moduleName grabs the parent of Partial!(), it then attempts to instantiate another instance of moduleName with the exact same argument again - hence the error about a recursive alias declaration.
My guess is that the problem relates to the fact that Type is an eponymous template. So, the templated type inside the template has the same name. And it seems to only happen when the type inside the template is itself templated. And unsurprisingly, if that's fully written out as
So, the bug here is that in this particular case, __traits(parent, ...) is giving back the same symbol that it's given instead of the parent of that symbol.
The instance where I ran into this in real code of course had template parameters for both templates, so the number of template parameters doesn't seem to matter. The example here is simply the simplest test case that I found when attempting to reduce it.
The text was updated successfully, but these errors were encountered:
This code
fails to compile, printing out
parentOf
is a private trait in std.traits which is a wrapper around__traits(parent, ...)
. So, the line that's failing is basicallyalias moduleName = moduleName!(__traits(parent, T));
and as the
pragma(msg, ...)
line shows, the parent ofPartial!()
is apparently itself. So, whenmoduleName
grabs the parent ofPartial!()
, it then attempts to instantiate another instance ofmoduleName
with the exact same argument again - hence the error about a recursive alias declaration.My guess is that the problem relates to the fact that
Type
is an eponymous template. So, the templated type inside the template has the same name. And it seems to only happen when the type inside the template is itself templated. And unsurprisingly, if that's fully written out asthe error is the same.
So, the bug here is that in this particular case,
__traits(parent, ...)
is giving back the same symbol that it's given instead of the parent of that symbol.The instance where I ran into this in real code of course had template parameters for both templates, so the number of template parameters doesn't seem to matter. The example here is simply the simplest test case that I found when attempting to reduce it.
The text was updated successfully, but these errors were encountered: