xref: /PHP-8.1/Zend/tests/bug79657.phpt (revision df2db7fc)
1--TEST--
2Bug #79657: "yield from" hangs when invalid value encountered
3--FILE--
4<?php
5
6function throwException(): iterable
7{
8    throw new Exception();
9}
10
11function loop(): iterable
12{
13    $callbacks = [
14        function () {
15            yield 'first';
16        },
17        function () {
18            yield from throwException();
19        }
20    ];
21
22    foreach ($callbacks as $callback) {
23        yield from $callback();
24    }
25}
26
27function get(string $first, int $second): array
28{
29    return [];
30}
31
32get(...loop());
33
34?>
35--EXPECTF--
36Fatal error: Uncaught Exception in %s:%d
37Stack trace:
38#0 %s(%d): throwException()
39#1 %s(%d): {closure}()
40#2 %s(%d): loop()
41#3 {main}
42  thrown in %s on line %d
43