Thread overview
[Issue 5795] New: enum x = CustomType; should be a syntax error
Mar 30, 2011
kennytm@gmail.com
Apr 09, 2011
Stewart Gordon
Jun 19, 2011
kennytm@gmail.com
March 30, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5795

           Summary: enum x = CustomType; should be a syntax error
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2011-03-30 08:15:15 PDT ---
Currently (v2.052) it is possible to do

-------

struct Bar {    // Bar can be a struct, a class, a union or an enum.
    int x;
    int y;
}

void main() {
    enum z = Bar;      // <------
    auto w = z(1, 2);
}

-------

The effect is the same as 'alias Bar z;'. However, the RHS of an 'enum' statement should only accept an AssignExpression, not a custom type. Either the D compiler should reject this, or the spec should be clarified to allow this.

In 2.042 this was a syntax error. http://ideone.com/BNcSh

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5795


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
           Severity|normal                      |regression


--- Comment #1 from Stewart Gordon <smjg@iname.com> 2011-04-09 07:51:04 PDT ---
(In reply to comment #0)
> In 2.042 this was a syntax error. http://ideone.com/BNcSh

Looks to me like a semantic, not syntax, error.  It can't be a syntax error, because that would cause it to fail if Bar is the name of a compile-time constant.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5795


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from kennytm@gmail.com 2011-06-19 04:48:25 PDT ---
*** This issue has been marked as a duplicate of issue 4206 ***

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