File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Generator exceptions during shutdown should not be swallowed
3
+ --FILE--
4
+ <?php
5
+
6
+ function gen () {
7
+ try {
8
+ echo "before yield \n" ;
9
+ yield ;
10
+ echo "after yield \n" ;
11
+ } finally {
12
+ echo "before yield in finally \n" ;
13
+ yield ;
14
+ echo "after yield in finally \n" ;
15
+ }
16
+ echo "after finally \n" ;
17
+ }
18
+
19
+ $ gen = gen ();
20
+ $ gen ->rewind ();
21
+
22
+ ?>
23
+ --EXPECTF--
24
+ before yield
25
+ before yield in finally
26
+
27
+ Fatal error: Uncaught Error: Cannot yield from finally in a force-closed generator in %s:%d
28
+ Stack trace:
29
+ #0 {main}
30
+ thrown in %s on line %d
Original file line number Diff line number Diff line change @@ -824,9 +824,10 @@ ZEND_API void zend_generator_resume(zend_generator *orig_generator) /* {{{ */
824
824
if (UNEXPECTED (EG (exception ) != NULL )) {
825
825
if (generator == orig_generator ) {
826
826
zend_generator_close (generator , 0 );
827
- if (EG (current_execute_data ) &&
828
- EG (current_execute_data )-> func &&
829
- ZEND_USER_CODE (EG (current_execute_data )-> func -> common .type )) {
827
+ if (!EG (current_execute_data )) {
828
+ zend_throw_exception_internal (NULL );
829
+ } else if (EG (current_execute_data )-> func &&
830
+ ZEND_USER_CODE (EG (current_execute_data )-> func -> common .type )) {
830
831
zend_rethrow_exception (EG (current_execute_data ));
831
832
}
832
833
} else {
You can’t perform that action at this time.
0 commit comments