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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1610 - Enum.stringof is int, not the name of the enum
Summary: Enum.stringof is int, not the name of the enum
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL:
Keywords: wrong-code
Depends on:
Blocks:
Reported: 2007年10月24日 10:56 UTC by Andrei Alexandrescu
Modified: 2014年03月01日 00:35 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2007年10月24日 10:56:32 UTC
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 Ary Borenszweig 2007年10月24日 11:15:32 UTC
d-bugmail@puremagic.com escribi
Comment 2 Moritz Warning 2008年07月22日 12:51:57 UTC
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 BCS 2008年07月22日 13:26:12 UTC
this issue is also in latest V1 so switching the version to that
Comment 4 Walter Bright 2008年12月08日 00:53:23 UTC
Fixed in DMD 1.037 and 2.021


AltStyle によって変換されたページ (->オリジナル) /