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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 15 15:01:25 UTC 2019


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

--- Comment #6 from David Eckardt <david.eckardt at frequenz.io> ---
I see two more issues here.

1. For both suffix-less integer literals and `enum name = value` style (i.e.
implicit type, no braces) `typeof` yields `int` although they may be coerced
into a different type. The same applies for `sizeof` and `alignof. This can
cause subtle bugs which are hard to track down (sorry, I am a bit upset because
it just happened to me). `typeof`, `sizeof` and the like should be consistent
here. As long as they are not, the way of working around type coercion and
avoiding bugs is to use `cast(typeof(expression))expression`, which needs an
explanation or the next person looking at the code will have a hard time trying
to understanding what it is for.

2. Enums and literals of integer arrays such as `[1, 2, 3]` should not match
`char[]`. Even `ubyte[]` cannot be implicitly cast to `char[]`.

--


More information about the Digitalmars-d-bugs mailing list