void testfunc()
{
static int i;
i++;
scope(exit) printf( "i=%d\n", --i);
if (i==10)
throw new Exception(``);
testfunc;
}
void main()
{
try
{
testfunc;
}
finally
{}
printf(`hello`);
}
Comment #1 by braddr — 2007-04-05T02:24:00Z
What happens when you run it? What do you expect it to do that it's not doing?
When I run it I see it print 10 down to 1 and then print Error:, exactly as I'd expect (though a linefeed would be nice, that's not what I suspect you're reporting).
I suspect what you're expecting is that the finally block doesn't stop the throw from propagating. If that's what you expect you should have used 'catch' rather than 'finally'.
IE, there's no bug here as far as I can tell. If there is, you'll need to be much more informative about what this report is about. In the future, please try to include that type of information with your report so that less guessing is required to evaluate the bug report.
Comment #2 by thomas-dloop — 2007-04-05T03:29:10Z
Use "catch" instead of "finally" if you like to see "hello" or put the printf
inside the finally scope.
Comment #3 by thomas-dloop — 2007-04-05T05:26:47Z
(In reply to comment #1)
> When I run it I see it print 10 down to 1 and then print Error:, exactly as
I'd expect (though a linefeed
> would be nice, that's not what I suspect you're reporting).
Do you really see 10 .. 1 instead of 9 .. 0 ?
Comment #4 by braddr — 2007-04-05T12:01:03Z
Sorry, you're right, 9..0.
Comment #5 by davidl — 2007-04-09T04:06:02Z
Oh, it's too common for me to think it does the same as other language, like delphi
try finally in delphi does stop the propagating