Bug 24684 – Bad diagnostic for an enum member in an enum that use another enum as base type

Status
NEW
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-07-25T18:00:53Z
Last change time
2024-12-13T19:36:45Z
Keywords
diagnostic
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#18262 →

Comments

Comment #0 by b2.temp — 2024-07-25T18:00:53Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:36:45Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18262 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB