mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Rethrow generator exception even without active stack frame
This commit is contained in:
commit
bfb38c3592
2 changed files with 34 additions and 3 deletions
30
Zend/tests/generators/exception_during_shutdown.phpt
Normal file
30
Zend/tests/generators/exception_during_shutdown.phpt
Normal file
|
@ -0,0 +1,30 @@
|
|||
--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
|
|
@ -824,9 +824,10 @@ try_again:
|
|||
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||
if (generator == orig_generator) {
|
||||
zend_generator_close(generator, 0);
|
||||
if (EG(current_execute_data) &&
|
||||
EG(current_execute_data)->func &&
|
||||
ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) {
|
||||
if (!EG(current_execute_data)) {
|
||||
zend_throw_exception_internal(NULL);
|
||||
} else if (EG(current_execute_data)->func &&
|
||||
ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) {
|
||||
zend_rethrow_exception(EG(current_execute_data));
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue