http://d.puremagic.com/issues/show_bug.cgi?id=8157
Summary: Disallow (dis)equality among two different enums Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2012-05-28 13:57:33 PDT --- This enhancement request is related to Issue 3999 but it's not the same problem. Issue 3999 asks to statically disallow: enum E1 { A, B } enum E2 { C, D } void main() { E1 a; assert(a == 0); } While this issue asks to statically disallow: enum E1 { A, B } enum E2 { C, D } void main() { E1 a; assert(a == E2.C); assert(a != E2.C); } (Well, Issue 3999 asks to disallow both cases, so this issue is a subset of Issue 3999 .) Discussion: http://forum.dlang.org/thread/lyzudurkvguonbmmj...@forum.dlang.org See an answer by Andrei Alexandrescu: http://forum.dlang.org/thread/lyzudurkvguonbmmj...@forum.dlang.org#post-jpvvm2:242d8l:241:40digitalmars.com > I do agree that it's wrong to _conflate_ the enumerated value with it > ordinal, so in this program neither comparison should compile without an > explicit cast: > > enum E1 { A, B } > enum E2 { C, D } > > void main() { > E1 a; > assert(a == 0); > assert(a == E2.C); > } > > The first one is probably difficult to disallow at this time, but the > second one almost always indicates a bug, confusion, or abuse on the > user side. We should disallow it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------