On Wednesday, 23 October 2013 at 08:11:59 UTC, Kenji Hara wrote:
On Wednesday, 23 October 2013 at 07:22:56 UTC, simendsjo wrote:
I've stumbled upon a strange bug, and I'm not sure what I
should write in the bug report. Could someone explain what's
going on here or file the bug for me?
template A(alias T) {
alias A = T;
}
void main() {
struct S1 { S1* p; }
static assert(is(typeof(A!(S1.init.p)) == S1*)); // ok
pragma(msg, "NULL: ", typeof(A!(null))); // fail: S1*
struct S2 { S2* p; }
static assert(is(typeof(A!(S2.init.p)) == S2*)); // fail:
S1*
}
A!(S1.init.p) is mostly same as A!( cast(S1*)null ), because
the expression S1.init.p is interpreted to a null value.
1. But current ABI does not support "a typed null template
value argument" because all of null expression on template
argument are mangled to 'n'. So the type of null value will be
never encoded in the mangled name, and the three instantiations
A!(S1.init.p), A!(null) and A!(S2.init.p) will have exactly
same mangling.
2. However, the first instantiation A!(S1.init.p) wrongly
caches the null value type (== S1*), and it appears in
following instantiations during semantic analysis phase.
#2 is definitely a front-end bug. However I'm not sure the
current ABI definition issue (== #2) is a language spec bug or
not...
Kenji Hara
Ok. Filed a bug. Probably not a good description, but I linked to
your post: http://d.puremagic.com/issues/show_bug.cgi?id=11328