1--TEST--
2Verify yield from on generators being properly cycle collected
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7
8function root() {
9    global $gens; // create cyclic reference to root
10    try {
11        yield 1;
12    } finally {
13        var_dump($gens);
14    }
15}
16
17function gen($x) {
18    global $gens;
19    yield from $gens[] = $x ? gen(--$x) : root();
20}
21
22$gen = $gens[] = gen(2);
23var_dump($gen->current());
24unset($gen, $gens);
25print "collect\n";
26gc_collect_cycles();
27print "end\n";
28
29?>
30--EXPECTF--
31int(1)
32collect
33array(4) {
34  [0]=>
35  object(Generator)#%d (1) {
36    ["function"]=>
37    string(3) "gen"
38  }
39  [1]=>
40  object(Generator)#%d (1) {
41    ["function"]=>
42    string(3) "gen"
43  }
44  [2]=>
45  object(Generator)#%d (1) {
46    ["function"]=>
47    string(3) "gen"
48  }
49  [3]=>
50  object(Generator)#%d (1) {
51    ["function"]=>
52    string(4) "root"
53  }
54}
55end
56