(Set version as 1.012, since 1.013 wasn't in the list yet.) template T(char[] s) { const char[] T = s; } char[] f(char[] s) { return s; } void main() { int foo; assert (foo.stringof == f(foo.stringof)); // works assert (foo.stringof == T!(foo.stringof)); // fails } T!(foo.stringof) results in "int", it should be "foo".
*** Bug 1465 has been marked as a duplicate of this bug. ***
The following patch to mtype.c fix the issue: --- ..\src\orig\mtype.cpp Thu Sep 03 01:01:40 2009 +++ ..\src\dmd\mtype.cpp Sat Sep 05 16:42:50 2009 @@ -4530,6 +4530,11 @@ goto Lerror; goto L3; } + else if(v && id == Id::stringof) { + e = new DsymbolExp(loc, s, 0); + *pe = new DotIdExp(loc, e, id); + return; + } t = s->getType(); if (!t && s->isDeclaration()) t = s->isDeclaration()->type; It turns out stringof was applied on the type of the Dsymbol, not the symbol itself.
Cool! Add 'patch' to the list of keywords when you've submitted a patch, it makes them easier to track.
Fixed dmd 1.048 and 2.033