https://issues.dlang.org/show_bug.cgi?id=23988
Issue ID: 23988 Summary: Conditional Exp does not bring enums to correct common type if one leg is const Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: bugzi...@digitalmars.com Consider: enum E : ubyte { A } pragma(msg, "test1 ", typeof(1 ? E.A : E.A)); pragma(msg, "test2 ", typeof(1 ? E.A : cast(const)E.A)); which prints: test1 E test2 int when it should print: test1 E test2 const(E) The spec sez: "If either the second or third expressions are of type void, then the resulting type is void. Otherwise, the second and third expressions are implicitly converted to a common type which becomes the result type of the conditional expression." https://dlang.org/spec/expression.html#conditional_expressions Note that it doesn't exactly say what the common type is, but what the compiler is doing is not expected. But the most obvious result should be const(E). --