http://d.puremagic.com/issues/show_bug.cgi?id=4564


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugd...@yahoo.com.au


--- Comment #1 from Don <clugd...@yahoo.com.au> 2010-08-10 00:45:06 PDT ---
When an error occurs in ForeachRangeStatement::semantic, it returns this.
That's a problem because foreachrangestatement doesn't support blockExit;
foreachrange MUST be turned into a for statement during the semantic pass.
I found a few variations of this error.

Now that we have a working _error type, it seems perfectly fine to just let it
through: the test suite passes. This also has the advantage that errors in the
foreach body are reported.

PATCH:

Statement *ForeachRangeStatement::semantic, line 2130.


        /* Must infer types from lwr and upr
         */
        Type *tlwr = lwr->type->toBasetype();
        if (tlwr->ty == Tstruct || tlwr->ty == Tclass)
        {
            /* Just picking the first really isn't good enough.
             */
            arg->type = lwr->type->mutableOf();
        }
        else
        {
            AddExp ea(loc, lwr, upr);
            Expression *e = ea.typeCombine(sc);
-            if (e->op == TOKerror)
-                return this;
            arg->type = ea.type->mutableOf();
            lwr = ea.e1;
            upr = ea.e2;
        }

EXTENDED TEST CASE
struct Bug4564{}

void bug4564()
{
    foreach(i; 3.1 ..Bug4564()) {
        foreach(j; 2.1..Bug4564()) {}
    }
    foreach(i; 0..undef){
       thisShouldGenerateAnError(); 
     }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to