July 25 [Issue 24684] New: Bad diagnostic for an enum member in an enum that use another enum as base type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24684 Issue ID: 24684 Summary: Bad diagnostic for an enum member in an enum that use another enum as base type Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: diagnostic Severity: minor Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: b2.temp@gmx.com For ``` enum A1 : int { a, b, } enum A2 : A1 { c, // does not require +1 d, // requires + 1 } ``` The definition of A2.d causes the error > /tmp/temp_7F4942E9C090.d(10,5): Error: comparison between different enumeration types `A2` and `A1`; If this behavior is intended consider using `std.conv.asOriginalType` which makes no sense. In fact the real problem is that `A2.d` violates the specification 18.1.5 (https://dlang.org/spec/enum.html#named_enums), specifically _"it is given the value of the previous EnumMember + 1_". In consequence a better message would be that `d` value cannot be automatically defined because the base type does not support increment. -- |
Copyright © 1999-2021 by the D Language Foundation