summaryrefslogtreecommitdiff
path: root/Zend/tests/bug79657.phpt
blob: fb2ccab3e3ef3fb7877491fcc84d1f6ebe1a4a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--TEST--
Bug #79657: "yield from" hangs when invalid value encountered
--FILE--
<?php

function throwException(): iterable
{
    throw new Exception();
}

function loop(): iterable
{
    $callbacks = [
        function () {
            yield 'first';
        },
        function () {
            yield from throwException();
        }
    ];

    foreach ($callbacks as $callback) {
        yield from $callback();
    }
}

function get(string $first, int $second): array
{
    return [];
}

get(...loop());

?>
--EXPECTF--
Fatal error: Uncaught Exception in %s:%d
Stack trace:
#0 %s(%d): throwException()
#1 %s(%d): {closure}()
#2 %s(%d): loop()
#3 {main}
  thrown in %s on line %d