[Issue 24684] New: Bad diagnostic for an enum member in an enum that use another enum as base type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 25 18:00:53 UTC 2024
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 at puremagic.com
Reporter: b2.temp at 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.
--
More information about the Digitalmars-d-bugs
mailing list