Bug 4206 – type accepted as enum initializer

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-05-19T00:47:00Z
Last change time
2011-10-07T16:30:11Z
Keywords
accepts-invalid, patch
Assigned to
nobody
Creator
r.sagitario
Depends on
2414

Comments

Comment #0 by r.sagitario — 2010-05-19T00:47:23Z
trying to compile the latet phobos revision, I've hit this assert: std\bind.d(295): Error: static assert (isTypeTuple!(Tuple!(int))) is false which boils down to the template isExpressionTuple not returning the correct value. This is caused by alias int myint; enum var = myint; being accepted as correct syntax while "enum var = int;" is not. This happens for every DMD version I have tested (latest svn, 2.046, 2.042, 1.056).
Comment #1 by smjg — 2010-05-27T19:36:23Z
Strange that you're getting this in 1.056 - I've always understood enums without {} to be a D2-specific feature. I certainly can't reproduce under 1.061. But under 2.046: ---------- alias int myint; enum var = myint; pragma(msg, var); pragma(msg, typeof(var)); ---------- int bz4206.d(5): Error: argument int to typeof is not an expression void ---------- This should error at line 2 - myint is a type, not a value. But I wonder if it's by any chance related to issue 2414.
Comment #2 by r.sagitario — 2010-05-28T12:18:05Z
You're right, it correctly does not compile with dmd 1.056. I must have been halucinating. Also, "enum { var = myint };" causes an error. The use case that was failing with D2 is pragma(msg, __traits(compiles, { enum var = myint; })); and outputs "true".
Comment #3 by k.hara.pg — 2011-06-19T04:06:19Z
On dmd 2.054 (d36b3b12fc4814e59f3a0d680b8700e787b1ceff), issue 2414 may have been resolved. But "enum { var = myint };" does not cause an error. I think this issue does not depend on 2414,
Comment #4 by kennytm — 2011-06-19T04:48:25Z
*** Issue 5795 has been marked as a duplicate of this issue. ***
Comment #5 by yebblies — 2011-07-02T12:15:26Z
Comment #6 by bugzilla — 2011-10-07T16:30:11Z