Bug 1610 – Enum.stringof is int, not the name of the enum

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-10-24T10:56:00Z
Last change time
2014-03-01T00:35:50Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
andrei

Comments

Comment #0 by andrei — 2007-10-24T10:56:32Z
import std.stdio; enum ABC { a, b, c } void main() { writeln(ABC.stringof); } // prints "int" This causes major issues in reflective and serialization code. The .stringof should evaluate to the name of the enum, e.g. "ABC".
Comment #1 by ary — 2007-10-24T11:15:32Z
Comment #2 by moritzwarning — 2008-07-22T12:51:57Z
I have to deal with this problem in a template function that is used with a lot of different enum types (by some other bigger templates). But not handled enum types hit a static assert. I wrote different template functions before but hit some limitations that forced me to put everything in the same function using static ifs. Because T.stringof is almost always "int", I have a hard time to find out what enum is not handled. I hope this problem will be addressed soon.
Comment #3 by shro8822 — 2008-07-22T13:26:12Z
this issue is also in latest V1 so switching the version to that
Comment #4 by bugzilla — 2008-12-08T00:53:23Z
Fixed in DMD 1.037 and 2.021