[Issue 9930] New: Disallow accessing enum members through enum instance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 14 08:28:04 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9930

           Summary: Disallow accessing enum members through enum instance
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-04-14 08:28:02 PDT ---
enum E
{
    A,
    B
}

void main()
{
    E e;

    if (e.A)  // should have been "if e == E.A"
    {
    }
}

This compiles, and it was a bug in my code. I don't see the benefit of being
able to access enum member through the instance instead of through the type. So
I think the above should become an error.

Of course "if (E.A)" through the type is and will be allowed to compile, but
the above might just catch a bug or two in user-code (it certainly wasted my
time tracking down the bug).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list