[Issue 24656] New: enums with explicit EnumBaseType incorrectly matching multiple overloads.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 9 19:15:41 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24656
Issue ID: 24656
Summary: enums with explicit EnumBaseType incorrectly matching
multiple overloads.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
The following code fails to compile due to matching multiple overloads, which
shouldn’t be correct.
```
import std;
void foo(ubyte x){
writeln("foo(ubyte)");
}
void foo(byte x){
writeln("foo(byte)");
}
enum E: ubyte {
A = 0,
B = 1,
Z = 255,
}
void main(){
ubyte a = 1;
byte b = 2;
foo(a); // ok
foo(b); // ok
foo(E.Z); // ok
foo(E.A); // matches both foo(ubyte) and foo(byte)
}
```
--
More information about the Digitalmars-d-bugs
mailing list