Bug 2861 – Forward reference of .stringof in a template gives wrong value

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-04-20T04:53:00Z
Last change time
2014-04-18T09:12:04Z
Keywords
wrong-code
Assigned to
nobody
Creator
clugdbug
Blocks
340

Comments

Comment #0 by clugdbug — 2009-04-20T04:53:29Z
If you reverse the order of the declaration of x and Type, it works correctly. For D2, change declaration of x to: enum x = Type.stringof; This is very similar to bug 934. With my patch applied, the equivalent situation for .mangleof works correctly. ---- template Templ(T) { const char[] x = Type.stringof; alias T Type; } void main() { static assert(Templ!(int).x =="int"); }
Comment #1 by clugdbug — 2009-08-31T07:57:51Z
Fixed DMD2.030 and 1.045. This works now. Test case was wrong, though, should have been: -- template Templ(T) { const char[] x = (Type).stringof; alias T Type; } void main() { static assert(Templ!(int).x =="int"); }