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

Changeset 608

Show
Ignore:
Timestamp:
08/09/10 05:30:23 (14 years ago)
Author:
walter
Message:

bugzilla 3326 $ in delegate literal causes Access Violation

Files:

Legend:

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

    r607 r608  
    13041304 * rather than the current one. 
    13051305 */ 
    13061306 
    13071307void VarDeclaration::checkNestedReference(Scope *sc, Loc loc) 
    13081308{ 
    13091309    //printf("VarDeclaration::checkNestedReference() %s\n", toChars()); 
    13101310    if (parent && !isDataseg() && parent != sc->parent) 
    13111311    { 
    13121312        // The function that this variable is in 
    13131313        FuncDeclaration *fdv = toParent()->isFuncDeclaration(); 
    13141314        // The current function 
    13151315        FuncDeclaration *fdthis = sc->parent->isFuncDeclaration(); 
    13161316 
    13171317        if (fdv && fdthis) 
    13181318        { 
    13191319            if (loc.filename) 
    13201320                fdthis->getLevel(loc, fdv); 
    13211321            nestedref = 1; 
    13221322            fdv->nestedFrameRef = 1; 
    13231323            //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars()); 
     1324            // __dollar creates problems because it isn't a real variable Bugzilla 3326 
     1325            if (ident == Id::dollar) 
     1326                ::error(loc, "cannnot use $ inside a function literal"); 
    13241327        } 
    13251328    } 
    13261329} 
    13271330 
    13281331/******************************* 
    13291332 * Does symbol go into data segment? 
    13301333 * Includes extern variables. 
    13311334 */ 
    13321335 
    13331336int VarDeclaration::isDataseg() 
    13341337{ 
    13351338#if 0 
    13361339    printf("VarDeclaration::isDataseg(%p, '%s')\n", this, toChars()); 
    13371340    printf("%llx, %p, %p\n", storage_class & (STCstatic | STCconst), parent->isModule(), parent->isTemplateInstance()); 
    13381341    printf("parent = '%s'\n", parent->toChars()); 
    13391342#endif 
    13401343    Dsymbol *parent = this->toParent(); 
    13411344    if (!parent && !(storage_class & (STCstatic | STCconst))) 
    13421345    {   error("forward referenced"); 
    13431346        type = Type::terror; 
  • trunk/src/declaration.c

    r607 r608  
    14261426            for (int i = 0; i < nestedrefs.dim; i++) 
    14271427            {   FuncDeclaration *f = (FuncDeclaration *)nestedrefs.data[i]; 
    14281428                if (f == fdthis) 
    14291429                    goto L1; 
    14301430            } 
    14311431            nestedrefs.push(fdthis); 
    14321432          L1: ; 
    14331433 
    14341434 
    14351435            for (int i = 0; i < fdv->closureVars.dim; i++) 
    14361436            {   Dsymbol *s = (Dsymbol *)fdv->closureVars.data[i]; 
    14371437                if (s == this) 
    14381438                    goto L2; 
    14391439            } 
    14401440 
    14411441            fdv->closureVars.push(this); 
    14421442          L2: ; 
    14431443 
    14441444            //printf("fdthis is %s\n", fdthis->toChars()); 
    14451445            //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars()); 
     1446            // __dollar creates problems because it isn't a real variable Bugzilla 3326 
     1447            if (ident == Id::dollar) 
     1448                ::error(loc, "cannnot use $ inside a function literal"); 
    14461449        } 
    14471450    } 
    14481451} 
    14491452 
    14501453/**************************** 
    14511454 * Get ExpInitializer for a variable, if there is one. 
    14521455 */ 
    14531456 
    14541457ExpInitializer *VarDeclaration::getExpInitializer() 
    14551458{ 
    14561459    ExpInitializer *ei; 
    14571460 
    14581461    if (init) 
    14591462        ei = init->isExpInitializer(); 
    14601463    else 
    14611464    { 
    14621465        Expression *e = type->defaultInit(loc); 
    14631466        if (e) 
    14641467            ei = new ExpInitializer(loc, e); 
    14651468        else