[Issue 4016] New: const initializer cannot forward reference other const initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 27 05:45:38 PDT 2010


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

           Summary: const initializer cannot forward reference other const
                    initializer
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: r.sagitario at gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario at gmx.de> 2010-03-27 05:45:37 PDT ---
comipiling

----
const PM_QS_INPUT =         QS_INPUT;
const QS_INPUT =           2;
----

produces:
test.d(1): Error: forward reference of variable QS_INPUT

Here's a patch:

Index: expression.c
===================================================================
--- expression.c    (revision 421)
+++ expression.c    (working copy)
@@ -2395,7 +2395,9 @@
     {
     //printf("Identifier '%s' is a variable, type '%s'\n", toChars(),
v->type->toChars());
     if (!type)
-    {   type = v->type;
+    {   if (!v->type && v->scope)
+        v->semantic(v->scope);
+        type = v->type;
         if (!v->type)
         {    error("forward reference of %s %s", v->kind(), v->toChars());
         type = Type::terror;

-- 
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