Comment #0 by thelastmammoth — 2013-05-28T01:49:08Z
import std.stdio;
import std.traits;
template A(T){
struct A{
T x;
void foo(int z){}
}
}
void main(){
enum b=A!int.init;
auto c=A!int.init;
writeln(fullyQualifiedName!(A!int.init));
writeln(fullyQualifiedName!(b));
writeln(fullyQualifiedName!(c));
}
prints:
T
T
tests.main.main.c
is that normal to print T ?
Ok, there are two issues here.
First one is that identifier trait fails badly with temporaries, minimal example:
----------------------------------------
template oops(alias T)
{
enum oops = __traits(identifier, T);
}
struct A {}
pragma(msg, oops!(A.init));
void main()
{
}
----------------------------------------
Second looks like some sort of data reusage compiler bug - once identifier trait was called on a temporary, using it on normal symbols breaks too (yields same rersult).
Comment #3 by public — 2013-06-14T01:24:26Z
I feel like I need an advice from someone from core DMD team on this - should I try to detect and workaround incoming temporaries in std.traits code or this is __traits(identifier) bug and need to be fixed in DMD itself?
Comment #4 by andrej.mitrovich — 2014-04-24T12:14:30Z
(In reply to Dicebot from comment #2)
> Second looks like some sort of data reusage compiler bug - once identifier
> trait was called on a temporary, using it on normal symbols breaks too
> (yields same rersult).
Filed that as issue 14501.
Comment #6 by robert.schadek — 2024-12-01T16:17:45Z