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