xref: /PHP-8.2/Zend/tests/gh9916-009.phpt (revision 1173c2e6)
1--TEST--
2Bug GH-9916 009 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3--FILE--
4<?php
5$gen = (function() {
6    $x = new stdClass;
7    try {
8        print "Before suspend\n";
9        Fiber::suspend();
10        print "Not executed\n";
11    } finally {
12        print "Finally\n";
13        yield from ['foo' => new stdClass];
14        print "Not executed\n";
15    }
16})();
17$fiber = new Fiber(function() use ($gen, &$fiber) {
18    $gen->current();
19    print "Not executed\n";
20});
21$fiber->start();
22?>
23==DONE==
24--EXPECTF--
25Before suspend
26==DONE==
27Finally
28
29Fatal error: Uncaught Error: Cannot use "yield from" in a force-closed generator in %s:%d
30Stack trace:
31#0 [internal function]: {closure}()
32#1 %s(%d): Generator->current()
33#2 [internal function]: {closure}()
34#3 {main}
35  thrown in %s on line %d
36