Return doesn't really return

Jacob Carlborg doob at me.com
Sat Aug 4 09:23:27 PDT 2012


I have a piece of code that looks like this:

https://github.com/jacob-carlborg/dstep/blob/master/clang/Visitor.d#L168

If I change that "first" function to look like this:

@property ParamCursor first ()
{
     assert(any, "Cannot get the first parameter of an empty parameter 
list");

     foreach (c ; this)
         return c;

     assert(0);
}

Then the last assert is hit. The return statement ends the foreach-loop 
but it doesn't return from the function. I have not been able to create 
a small test case for this.

Have I done a mistake somewhere or is this a bug in DMD?

Mac OS X, DMD 2.059 or 2.060.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list