1--TEST--
2Exceptions in linear yield from setup
3--FILE--
4<?php
5function from($off) {
6    debug_print_backtrace();
7    yield $off + 1;
8}
9
10function gen() {
11    yield 1;
12    debug_print_backtrace();
13    yield 2;
14    yield from from(2);
15    debug_print_backtrace();
16}
17
18print "\nImplicit foreach:\n";
19foreach (gen() as $v) {
20    var_dump($v);
21}
22
23print "\nExplicit iterator:\n";
24for ($gen = gen(); $gen->valid(); $gen->next()) {
25    var_dump($gen->current());
26}
27?>
28--EXPECTF--
29Implicit foreach:
30int(1)
31#0 %s(%d): gen()
32int(2)
33#0 %s(%d): from(2)
34#1 %s(%d): gen()
35int(3)
36#0 %s(%d): gen()
37
38Explicit iterator:
39int(1)
40#0 [internal function]: gen()
41#1 %s(%d): Generator->next()
42int(2)
43#0 %s(%d): from(2)
44#1 [internal function]: gen()
45#2 %s(%d): Generator->next()
46int(3)
47#0 [internal function]: gen()
48#1 %s(%d): Generator->next()
49