Don <> changed:

           What    |Removed                     |Added
           Keywords|                            |patch

--- Comment #6 from Don <> 2010-04-14 07:52:15 PDT ---
The code I've previously posted is definitely incorrect. The problem here is
that the compiler's thinks that the struct is a field of the parent; and this
happens because the scope is wrong.

I'm really not sure where to fix this. One possibility is to add it to
CommaExp::semantic, creating a new scope whenever there's a declaration which
isn't in module scope. But I think the correct solution is to change the scope
for evaluating the default arguments, in mtype.c
around line 4766; 

        /* Create a scope for evaluating the default arguments for the
        Scope *argsc = sc->push();
        argsc->stc = 0;                 // don't inherit storage class
        argsc->protection = PROTpublic;
+        /* Compiler-generated comma expressions (such as struct constructors)
+         * can include a variable declaration. This declaration needs to go
+         * If we're inside a function, it can become a local variable of that
+         * but if not (for example, if it is a function default parameter), it
+         * its own scope.
+         */
+        if (!argsc->func) // not a nested function
+          argsc->parent = (Dsymbol*)sc->module;

But I don't know if it's OK to set the parent in this way. The cast is needed
only because mtype.c doesn't have the real definition of Module.
The patch to bug 2935 is required in addition to this one.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to