Return doesn't really return
Timon Gehr
timon.gehr at gmx.ch
Sat Aug 4 10:08:30 PDT 2012
On 08/04/2012 06:23 PM, Jacob Carlborg wrote:
> 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.
>
int opApply (Delegate dg)
{
auto result = clang_visitChildren(cursor,
&visitorFunction,cast(CXClientData) &dg);
return result == CXChildVisitResult.CXChildVisit_Break ? 1 : 0; //
culprit
}
More information about the Digitalmars-d-learn
mailing list