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

--- Comment #3 from David Eckardt <[email protected]> ---
(In reply to David Eckardt from comment #2)
> 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

Extended the example:

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

enum E: ushort {a = 10}

immutable y = E.a;

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

--

Reply via email to