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

Changeset 636

Show
Ignore:
Timestamp:
08/28/10 04:36:17 (14 years ago)
Author:
walter
Message:

Issue 4564 - ICE on undefined variable in foreach over 0 .. undef

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/statement.c

    r629 r636  
    21102110    { 
    21112111        arg->type = arg->type->semantic(loc, sc); 
    21122112        lwr = lwr->implicitCastTo(sc, arg->type); 
    21132113        upr = upr->implicitCastTo(sc, arg->type); 
    21142114    } 
    21152115    else 
    21162116    { 
    21172117        /* Must infer types from lwr and upr 
    21182118         */ 
    21192119        Type *tlwr = lwr->type->toBasetype(); 
    21202120        if (tlwr->ty == Tstruct || tlwr->ty == Tclass) 
    21212121        { 
    21222122            /* Just picking the first really isn't good enough. 
    21232123             */ 
    21242124            arg->type = lwr->type->mutableOf(); 
    21252125        } 
    21262126        else 
    21272127        { 
    21282128            AddExp ea(loc, lwr, upr); 
    21292129            Expression *e = ea.typeCombine(sc); 
    2130             if (e->op == TOKerror) 
    2131                 return this; 
    21322130            arg->type = ea.type->mutableOf(); 
    21332131            lwr = ea.e1; 
    21342132            upr = ea.e2; 
    21352133        } 
    21362134    } 
    21372135#if 1 
    21382136    /* Convert to a for loop: 
    21392137     *  foreach (key; lwr .. upr) => 
    21402138     *  for (auto key = lwr, auto tmp = upr; key < tmp; ++key) 
    21412139     * 
    21422140     *  foreach_reverse (key; lwr .. upr) => 
    21432141     *  for (auto tmp = lwr, auto key = upr; key-- > tmp;) 
    21442142     */ 
    21452143 
    21462144    ExpInitializer *ie = new ExpInitializer(loc, (op == TOKforeach) ? lwr : upr); 
    21472145    key = new VarDeclaration(loc, arg->type, arg->ident, ie); 
    21482146 
    21492147    Identifier *id = Lexer::uniqueId("__limit"); 
    21502148    ie = new ExpInitializer(loc, (op == TOKforeach) ? upr : lwr); 
    21512149    VarDeclaration *tmp = new VarDeclaration(loc, arg->type, id, ie);