Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 634

Show
Ignore:
Timestamp:
08/27/10 23:02:45 (14 years ago)
Author:
walter
Message:

bugzilla 190 - Cannot forward reference typedef/alias in default value for function parameter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/expression.c

    r629 r634  
    39293929    return 0; 
    39303930} 
    39313931 
    39323932Expression *VarExp::semantic(Scope *sc) 
    39333933{   FuncLiteralDeclaration *fd; 
    39343934 
    39353935#if LOGSEMANTIC 
    39363936    printf("VarExp::semantic(%s)\n", toChars()); 
    39373937#endif 
    39383938    if (!type) 
    39393939    {   type = var->type; 
    39403940#if 0 
    39413941        if (var->storage_class & STClazy) 
    39423942        { 
    39433943            TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 
    39443944            type = new TypeDelegate(tf); 
    39453945            type = type->semantic(loc, sc); 
    39463946        } 
    39473947#endif 
    39483948    } 
     3949 
     3950    if (type && !type->deco) 
     3951        type = type->semantic(loc, sc); 
    39493952 
    39503953    /* Fix for 1161 doesn't work because it causes protection 
    39513954     * problems when instantiating imported templates passing private 
    39523955     * variables as alias template parameters. 
    39533956     */ 
    39543957    //accessCheck(loc, sc, NULL, var); 
    39553958 
    39563959    VarDeclaration *v = var->isVarDeclaration(); 
    39573960    if (v) 
    39583961    { 
    39593962        if (v->isConst() && v->type && type->toBasetype()->ty != Tsarray && v->init) 
    39603963        { 
    39613964            ExpInitializer *ei = v->init->isExpInitializer(); 
    39623965            if (ei) 
    39633966            { 
    39643967                //ei->exp->implicitCastTo(sc, type)->print(); 
    39653968                return ei->exp->implicitCastTo(sc, type); 
    39663969            } 
    39673970        } 
    39683971        v->checkNestedReference(sc, loc); 
     
    54625465                        e = type->defaultInit(); 
    54635466                        e->loc = loc; 
    54645467                        return e; 
    54655468                    } 
    54665469                } 
    54675470                if (v->needThis()) 
    54685471                { 
    54695472                    if (!eleft) 
    54705473                        eleft = new ThisExp(loc); 
    54715474                    e = new DotVarExp(loc, eleft, v); 
    54725475                    e = e->semantic(sc); 
    54735476                } 
    54745477                else 
    54755478                { 
    54765479                    e = new VarExp(loc, v); 
    54775480                    if (eleft) 
    54785481                    {   e = new CommaExp(loc, eleft, e); 
    54795482                        e->type = v->type; 
    54805483                    } 
    54815484                } 
    5482                 return e->deref(); 
     5485                //return e->deref(); 
     5486                e = e->deref(); 
     5487                return e->semantic(sc); 
    54835488            } 
    54845489 
    54855490            FuncDeclaration *f = s->isFuncDeclaration(); 
    54865491            if (f) 
    54875492            { 
    54885493                //printf("it's a function\n"); 
    54895494                if (f->needThis()) 
    54905495                { 
    54915496                    if (!eleft) 
    54925497                        eleft = new ThisExp(loc); 
    54935498                    e = new DotVarExp(loc, eleft, f); 
    54945499                    e = e->semantic(sc); 
    54955500                } 
    54965501                else 
    54975502                { 
    54985503                    e = new VarExp(loc, f); 
    54995504                    if (eleft) 
    55005505                    {   e = new CommaExp(loc, eleft, e); 
    55015506                        e->type = f->type; 
    55025507                    } 
  • trunk/src/expression.c

    r629 r634  
    41984198Expression *VarExp::semantic(Scope *sc) 
    41994199{   FuncLiteralDeclaration *fd; 
    42004200 
    42014201#if LOGSEMANTIC 
    42024202    printf("VarExp::semantic(%s)\n", toChars()); 
    42034203#endif 
    42044204//    if (var->sem == SemanticStart && var->scope)      // if forward referenced 
    42054205//      var->semantic(sc); 
    42064206    if (!type) 
    42074207    {   type = var->type; 
    42084208#if 0 
    42094209        if (var->storage_class & STClazy) 
    42104210        { 
    42114211            TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 
    42124212            type = new TypeDelegate(tf); 
    42134213            type = type->semantic(loc, sc); 
    42144214        } 
    42154215#endif 
    42164216    } 
    42174217 
     4218    if (type && !type->deco) 
     4219        type = type->semantic(loc, sc); 
     4220 
    42184221    /* Fix for 1161 doesn't work because it causes protection 
    42194222     * problems when instantiating imported templates passing private 
    42204223     * variables as alias template parameters. 
    42214224     */ 
    42224225    //accessCheck(loc, sc, NULL, var); 
    42234226 
    42244227    VarDeclaration *v = var->isVarDeclaration(); 
    42254228    if (v) 
    42264229    { 
    42274230#if 0 
    42284231        if ((v->isConst() || v->isImmutable()) && 
    42294232            type->toBasetype()->ty != Tsarray && v->init) 
    42304233        { 
    42314234            ExpInitializer *ei = v->init->isExpInitializer(); 
    42324235            if (ei) 
    42334236            { 
    42344237                //ei->exp->implicitCastTo(sc, type)->print(); 
    42354238                return ei->exp->implicitCastTo(sc, type); 
    42364239            } 
    42374240        } 
     
    58935896                { 
    58945897                    error("circular reference to '%s'", v->toChars()); 
    58955898                    return new ErrorExp(); 
    58965899                } 
    58975900                type = v->type; 
    58985901                if (v->needThis()) 
    58995902                { 
    59005903                    if (!eleft) 
    59015904                        eleft = new ThisExp(loc); 
    59025905                    e = new DotVarExp(loc, eleft, v); 
    59035906                    e = e->semantic(sc); 
    59045907                } 
    59055908                else 
    59065909                { 
    59075910                    e = new VarExp(loc, v); 
    59085911                    if (eleft) 
    59095912                    {   e = new CommaExp(loc, eleft, e); 
    59105913                        e->type = v->type; 
    59115914                    } 
    59125915                } 
    5913                 return e->deref(); 
     5916                //return e->deref(); 
     5917                e = e->deref(); 
     5918                return e->semantic(sc); 
    59145919            } 
    59155920 
    59165921            FuncDeclaration *f = s->isFuncDeclaration(); 
    59175922            if (f) 
    59185923            { 
    59195924                //printf("it's a function\n"); 
    59205925                if (f->needThis()) 
    59215926                { 
    59225927                    if (!eleft) 
    59235928                        eleft = new ThisExp(loc); 
    59245929                    e = new DotVarExp(loc, eleft, f); 
    59255930                    e = e->semantic(sc); 
    59265931                } 
    59275932                else 
    59285933                { 
    59295934                    e = new VarExp(loc, f, 1); 
    59305935                    if (eleft) 
    59315936                    {   e = new CommaExp(loc, eleft, e); 
    59325937                        e->type = f->type; 
    59335938                    }