[Issue 247] New: Cannot return from nested functions in contracts

Thomas Kuehne thomas-dloop at kuehne.cn
Tue Aug 15 02:53:05 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail at puremagic.com schrieb am 2006-07-09:
> http://d.puremagic.com/issues/show_bug.cgi?id=247

> void foo()
> in {
>         static void checkParameters() {
>                 return;
>         }
>
>         checkParameters();
> } body {        
> }
> --
> The above fails, because "return statements cannot be in contracts" --- which
> makes sense, but the return statement in this case is not returning from the
> contract, but from a function within the contract. The D documentation says
> that "[a]ny other D statement or expression [than assert] is allowed in the
> [contract] bodies", so I see no reason for this not to work.
>
> In the case of a void-returning function such as the above, it is naturally
> simple to sidestep the issue, but with a more complex function, such as a
> recursive one with many possible execution paths, this can be a real problem.

Added to DStress as
http://dstress.kuehne.cn/run/i/in_out_body_12_A.d
http://dstress.kuehne.cn/run/i/in_out_body_12_B.d
http://dstress.kuehne.cn/run/i/in_out_body_12_C.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFE4aGaLK5blCcjpWoRAgZRAJ0WShcQqmGExp/zXYR33E2w60S0mACeIxpb
xO5MG6ppSYP7j2YHVer7JMc=
=5OBw
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list