[Issue 1160] enums can not be forward referenced
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 10 14:52:41 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1160
------- Comment #1 from tomas at famolsen.dk 2008-01-10 16:52 -------
the simplest test case is something like this:
X x;
enum X { Y };
Fails to compile with 'enum is forward referenced' error.
This issue came up on IRC and I decided to take a look what was going on.
The issue is that the basetype cannot be resolved.
A working workaround is:
X x;
enum X : int { Y };
This patch (against LLVMDC, might not match 100%) ...
Index: dmd/declaration.c
===================================================================
--- dmd/declaration.c (revision 135)
+++ dmd/declaration.c (working copy)
@@ -642,6 +642,7 @@
Dsymbol *parent = toParent();
FuncDeclaration *fd = parent->isFuncDeclaration();
+ type->semantic(loc,sc);
Type *tb = type->toBasetype();
if (tb->ty == Tvoid && !(storage_class & STClazy))
{ error("voids have no value");
... also fixes the problem. I have no idea what other problems it might
introduce though... Also I doubt it will fix all the variations of this issue.
I haven't looked enough at the semantics code in DMD to fix this properly.
However, this seems like something that shouldn't be *that* hard to fix... Why
not put in the works for Type::toBaseType to be able to run semantics?
Please enlighten me (us) as to why this is implemented as it is right now!
--
More information about the Digitalmars-d-bugs
mailing list