Bug 5795 – enum x = CustomType; should be a syntax error

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-03-30T08:15:00Z
Last change time
2011-06-19T04:48:25Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
kennytm

Comments

Comment #0 by kennytm — 2011-03-30T08:15:15Z
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
Comment #1 by smjg — 2011-04-09T07:51:04Z
(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.
Comment #2 by kennytm — 2011-06-19T04:48:25Z
*** This issue has been marked as a duplicate of issue 4206 ***