[Issue 23981] New: enum siblings and struct member naming conflict undetected and counter intuitive path prefered
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 9 17:45:54 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23981
Issue ID: 23981
Summary: enum siblings and struct member naming conflict
undetected and counter intuitive path prefered
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dlang.org
Assignee: nobody at puremagic.com
Reporter: crazymonkyyy at gmail.com
```d
import std;
struct button_{
int j;
bool opCast(T:bool)(){
"casted".writeln;
return up;//down;
}
bool down(){
assert(j==0,"called down on something not shift "~j.to!string);
return true;
}
bool up(){
assert(0,"I thought I was calling down");
}
}
enum button{
shift=button_(0),down=button_(1)
}
unittest{
if(button.shift.down){
"shift was pressed".writeln;
}
}
enum abc{a,b,c}
unittest{
abc foo;
foo=foo.a.b.c.c.b.a;//?????????
}
```
I expect the enum button to contain a reference of shift that I can then ask if
its down
Instead, the shift has a sibling called down and that is the interpretation the
compiler prefers; this needs a warning or an error
--
More information about the Digitalmars-d-bugs
mailing list