[Issue 19399] Different Conversion Rules for Same Value and Type -- Enum

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 14 11:22:16 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19399

David Eckardt <david.eckardt at sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david.eckardt at sociomantic.c
                   |                            |om

--- Comment #2 from David Eckardt <david.eckardt at sociomantic.com> ---
This looks like a bug to me:

int f(ubyte x) { return x.sizeof; }
int f(ushort x)  { return x.sizeof; }

enum E: ushort {a = 10}

static assert(E.a.sizeof == E.sizeof); // succeeds
static assert(E.a.sizeof == f(E.a));  // fails, f(ubyte) is called

E.a.sizeof can be 1 or 2 depending on how it is used. This is obviously an
error. My guess is that for a function call “E.a” is treated as if it was the
numeric literal “10”, then typeof(10) is used to pick the function from the
overloads.

--


More information about the Digitalmars-d-bugs mailing list