Don <> changed:

           What    |Removed                     |Added
           Keywords|                            |patch

--- Comment #4 from Don <> 2010-07-15 14:42:34 PDT ---
This is a front-end problem.
ForeachStatement::semantic() immediately runs aggr->semantic(). 
In this case, aggr is an address of a nested function 'inner'.
AddrExp->semantic() turns it into a DelegateExp.

Later on in Foreach::semantic, if the aggregate is of delegate type, it wraps
it in a CallExp, then runs CallExp::semantic. The problem is that CallExp
assumes that semantic has NOT been run on its argument.
This works fine if the aggregate is a delegate variable. But if it's a delegate
expression, CallExp transforms the DelegateExp for 'inner' into a
DotVarExp(inner, inner). And then it's a mess.  CallExp needs to be passed
'inner', not the delegateExp.

I can see two possible fixes. 
(1) Change CallExp so that changes DelegateExp(f,f) into CallExp(f), if f is a
nested function, instead of changing it into a DotVarExp.

(2) If it's a delegate expression for a nested function, call the function
This patch implements the second method.

statement.c, Foreach::semantic(), line 1891

            else if (tab->ty == Tdelegate)
                /* Call:
                 *      aggr(flde)
                Expressions *exps = new Expressions();

+                if (aggr->op == TOKdelegate &&
+                    ((DelegateExp *)aggr)->func->isNested())
+                    e = new CallExp(loc, ((DelegateExp *)aggr)->e1, exps);
+                else
+                    e = new CallExp(loc, aggr, exps);
-                e = new CallExp(loc, aggr, exps);
                e = e->semantic(sc);

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

Reply via email to