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: nob...@puremagic.com
        ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisp...@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: -------

Reply via email to