1--TEST--
2Backtrace in deeply nested function call
3--EXTENSIONS--
4fiber
5--FILE--
6<?php
7
8function suspend_fiber(int $level): void
9{
10    if ($level >= 10) {
11        $value = \Fiber::suspend($level);
12        failing_function($value);
13    }
14
15    suspend_fiber($level + 1);
16}
17
18function failing_function(string $value): never
19{
20    throw_exception();
21}
22
23function throw_exception(): never
24{
25    throw new Exception;
26}
27
28$fiber = new Fiber(function (): void {
29    suspend_fiber(0);
30});
31
32$fiber->start();
33
34$fiber->resume('test');
35
36?>
37--EXPECTF--
38Fatal error: Uncaught Exception in %sbacktrace-deep-nesting.php:%d
39Stack trace:
40#0 %sbacktrace-deep-nesting.php(%d): throw_exception()
41#1 %sbacktrace-deep-nesting.php(%d): failing_function('test')
42#2 %sbacktrace-deep-nesting.php(%d): suspend_fiber(10)
43#3 %sbacktrace-deep-nesting.php(%d): suspend_fiber(9)
44#4 %sbacktrace-deep-nesting.php(%d): suspend_fiber(8)
45#5 %sbacktrace-deep-nesting.php(%d): suspend_fiber(7)
46#6 %sbacktrace-deep-nesting.php(%d): suspend_fiber(6)
47#7 %sbacktrace-deep-nesting.php(%d): suspend_fiber(5)
48#8 %sbacktrace-deep-nesting.php(%d): suspend_fiber(4)
49#9 %sbacktrace-deep-nesting.php(%d): suspend_fiber(3)
50#10 %sbacktrace-deep-nesting.php(%d): suspend_fiber(2)
51#11 %sbacktrace-deep-nesting.php(%d): suspend_fiber(1)
52#12 %sbacktrace-deep-nesting.php(%d): suspend_fiber(0)
53#13 [internal function]: {closure}()
54#14 %sbacktrace-deep-nesting.php(%d): Fiber->resume('test')
55#15 {main}
56  thrown in %sbacktrace-deep-nesting.php on line %d
57