digitalmars.D.bugs - [Issue 21460] New: implicit conversion between two unrelated enum is
- d-bugmail puremagic.com (36/36) Dec 08 2020 https://issues.dlang.org/show_bug.cgi?id=21460
https://issues.dlang.org/show_bug.cgi?id=21460 Issue ID: 21460 Summary: implicit conversion between two unrelated enum is accepted Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: accepts-invalid Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: b2.temp gmx.com This code compiles but should not --- enum Good : ubyte { a = 1 } enum Bad : ubyte { a = 2 } void main() { Good good; switch (good) { case Bad.a : break; default: } } --- The compilation halts if the base type, `ubyte`, is not specified. I dont see a specification for that behavior. The only implicit conv rule related to named enums is: "A named enum member can be implicitly cast to its EnumBaseType, but EnumBaseType types cannot be implicitly cast to an enum type." It is not clear if this covers the problem described in this report. --
Dec 08 2020