php-src/Zend/tests/generators/exception_during_shutdown.phpt
Nikita Popov 897d99c7a4 Rethrow generator exception even without active stack frame
Finally blocks in generators may be invoked during shutdown, in
which case we don't have a stack frame. Similar to what
zend_call_function does, we still need to rethrow these exceptions,
otherwise they will be hidden (and leak).
2019-12-18 11:04:15 +01:00

31 lines
565 B
PHP

--TEST--
Generator exceptions during shutdown should not be swallowed
--FILE--
<?php
function gen() {
try {
echo "before yield\n";
yield;
echo "after yield\n";
} finally {
echo "before yield in finally\n";
yield;
echo "after yield in finally\n";
}
echo "after finally\n";
}
$gen = gen();
$gen->rewind();
?>
--EXPECTF--
before yield
before yield in finally
Fatal error: Uncaught Error: Cannot yield from finally in a force-closed generator in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d