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--EXPECT--
31int(1)
32collect
33array(4) {
34  [0]=>
35  object(Generator)#1 (0) {
36  }
37  [1]=>
38  object(Generator)#2 (0) {
39  }
40  [2]=>
41  object(Generator)#3 (0) {
42  }
43  [3]=>
44  object(Generator)#4 (0) {
45  }
46}
47end
48