Bug 3651 – mangleof broken for enums

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
All
Creation time
2009-12-26T11:32:00Z
Last change time
2014-04-18T09:12:04Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
nfxjfg

Attachments

IDFilenameSummaryContent-TypeSize
549enum-mangleof.patchPatchtext/plain674

Comments

Comment #0 by nfxjfg — 2009-12-26T11:32:07Z
First off, this bug report is for dmd 1.053, not 1.051; but bugzilla let's me only select up to 1.051. .mangleof is broken for enums: enum foo { item, } //should output a mangled name with "foo" in it, but outputs "i" pragma(msg, foo.mangleof); void main() {} I apologize if this is a duplicate bug; there were quite a lot of enum bugs which look slightly similar (the compiler seems to reduce enums to ints prematurely in a lot of cases).
Comment #1 by mpiepk — 2010-01-14T05:43:12Z
Created attachment 549 Patch Patch against dmd 1.055. The problem is that mangleof is executed on the enum member type, not the enum type itself.
Comment #2 by clugdbug — 2010-01-28T00:47:21Z
> enum foo { > item, > } > //should output a mangled name with "foo" in it, but outputs "i" > pragma(msg, foo.mangleof); Are you sure that's what it should do? Why do you think the existing behaviour is wrong?
Comment #3 by nfxjfg — 2010-01-28T00:55:57Z
@Don: I'm pretty sure my bug report is correct. enums are the *only* type that behave different here. Further, if you get the mangle of a function or template that use enums as parameters, the enum gets mangled using the type name, not the base type. Why do you think the current behavior would be correct? Why would .mangleof for a type return the mangle for a completely *different* type?
Comment #4 by clugdbug — 2010-01-28T01:05:28Z
(In reply to comment #3) > @Don: I'm pretty sure my bug report is correct. enums are the *only* type that > behave different here. Further, if you get the mangle of a function or template > that use enums as parameters, the enum gets mangled using the type name, not > the base type. > > Why do you think the current behavior would be correct? Why would .mangleof for > a type return the mangle for a completely *different* type? Because enums aren't strong types. typeof(item) is int, not foo. 'foo' just seems to be an alias for int. (I think the existing behaviour is stupid, BTW).
Comment #5 by nfxjfg — 2010-01-28T01:14:41Z
>typeof(item) is int, not foo. Even then, typeof(foo) is foo, and not int. It's only logical that foo.mangleof should be the mangle for foo, not int. I don't know about item.mangelof. Is that even allowed?
Comment #6 by bugzilla — 2010-05-31T01:02:27Z