digitalmars.D.bugs - [Issue 8816] New: It should be illegal for enums to declare members named init, max, or min
- d-bugmail puremagic.com (35/35) Oct 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8816
- d-bugmail puremagic.com (6/6) Oct 14 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8816
- d-bugmail puremagic.com (11/11) Oct 14 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8816
http://d.puremagic.com/issues/show_bug.cgi?id=8816 Summary: It should be illegal for enums to declare members named init, max, or min Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com --- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2012-10-13 23:57:05 PDT --- TDPL (p.275) specifically allows for enums to declare members named min, max, and init and then immediately tells you that it's a dumb idea to do so. Allowing it is bound to break generic code, since it allows you to do nonsense like enum MyEnum : int {max, min, init} completely breaking any guarantees about what the mean. And note this fun situation: enum MyEnum : int { a, b, c, init } void main() { MyEnum e; assert(e == MyEnum.a); assert(MyEnum.init == MyEnum.a); } The first assertion passes and the second fails, meaning that the declartion of init has effectively hidden the real init. I'd strongly argue that allowing the overloading init, min, and max should be disallowed. Allowing it gains us nothing and just causes bugs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 13 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8816 --- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2012-10-14 00:05:18 PDT --- See also issue# 8817. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8816 Alex Rønne Petersen <alex lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alex lycus.org --- Comment #2 from Alex Rønne Petersen <alex lycus.org> 2012-10-14 09:36:24 CEST --- For what it's worth, I agree that it's nonsensical to even allow this. It's just inviting catastrophe. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2012