[Issue 21460] New: implicit conversion between two unrelated enum is accepted
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 8 11:57:29 UTC 2020
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 at puremagic.com
Reporter: b2.temp at 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.
--
More information about the Digitalmars-d-bugs
mailing list