File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #79657: "yield from" hangs when invalid value encountered
3
+ --FILE--
4
+ <?php
5
+
6
+ function throwException (): iterable
7
+ {
8
+ throw new Exception ();
9
+ }
10
+
11
+ function loop (): iterable
12
+ {
13
+ $ callbacks = [
14
+ function () {
15
+ yield 'first ' ;
16
+ },
17
+ function () {
18
+ yield from throwException ();
19
+ }
20
+ ];
21
+
22
+ foreach ($ callbacks as $ callback ) {
23
+ yield from $ callback ();
24
+ }
25
+ }
26
+
27
+ function get (string $ first , int $ second ): array
28
+ {
29
+ return [];
30
+ }
31
+
32
+ get (...loop ());
33
+
34
+ ?>
35
+ --EXPECTF--
36
+ Fatal error: Uncaught Exception in %s:%d
37
+ Stack trace:
38
+ #0 %s(%d): throwException()
39
+ #1 %s(%d): {closure}()
40
+ #2 %s(%d): loop()
41
+ #3 {main}
42
+ thrown in %s on line %d
Original file line number Diff line number Diff line change @@ -794,6 +794,7 @@ ZEND_API void zend_generator_resume(zend_generator *orig_generator) /* {{{ */
794
794
} else {
795
795
generator = zend_generator_get_current (orig_generator );
796
796
zend_generator_throw_exception (generator , NULL );
797
+ orig_generator -> flags &= ~ZEND_GENERATOR_DO_INIT ;
797
798
goto try_again ;
798
799
}
799
800
}
You can’t perform that action at this time.
0 commit comments