It shouldn't fail to compile. It means the same thing as a return inside a finally block. Not a bug.
Comment #2 by ddparnell — 2006-03-09T19:44:17Z
But it *does* fail to compile now. For example, this program ...
-------------------
import std.stdio;
int Foo(int x)
{
scope(exit) if (x < 5) return x+9;
return x;
}
void main()
{
for(int i = 0; i < 10; i++)
writefln("IN %s OUT %s", i, Foo(i));
}
-------------------
gives this compiler message ...
"test.d(4): return statements cannot be in finally bodies"
Comment #3 by thomas-dloop — 2006-03-10T00:46:38Z
(In reply to comment #1)
> It shouldn't fail to compile. It means the same thing as a return inside a
> finally block. Not a bug.
The correlation wiht finally isn't documented.
http://www.digitalmars.com/d/statement.html#try
# A FinallyStatement may not exit with a goto, break, continue, or
# return; nor may it be entered with a goto.
Thus the code below is illegal, yet compiles:
# int test(){
# scope(exit) return 0;
# }
# void test(){
# scope(exit) return 0;
# }