D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3651 - mangleof broken for enums
Summary: mangleof broken for enums
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2009-12-26 11:32 UTC by nfxjfg
Modified: 2014-04-18 09:12 UTC (History)
3 users (show)

See Also:


Attachments
Patch (674 bytes, patch)
2010-01-14 05:43 UTC, mpiepk
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description nfxjfg 2009-12-26 11:32:07 UTC
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 mpiepk 2010-01-14 05:43:12 UTC
Created attachment 549 [details]
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 Don 2010-01-28 00:47:21 UTC
> 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 nfxjfg 2010-01-28 00:55:57 UTC
@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 Don 2010-01-28 01:05:28 UTC
(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 nfxjfg 2010-01-28 01:14:41 UTC
>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 Walter Bright 2010-05-31 01:02:27 UTC
http://www.dsource.org/projects/dmd/changeset/508