xref: /PHP-8.2/Zend/tests/bug70944.phpt (revision f8d79582)
1--TEST--
2Bug #70944 (try{ } finally{} can create infinite chains of exceptions)
3--FILE--
4<?php
5try {
6    $e = new Exception("Foo");
7    try {
8        throw  new Exception("Bar", 0, $e);
9    } finally {
10        throw $e;
11    }
12} catch (Exception $e) {
13    var_dump((string)$e);
14}
15
16try {
17    $e = new Exception("Foo");
18    try {
19        throw new Exception("Bar", 0, $e);
20    } finally {
21        throw new Exception("Dummy", 0, $e);
22    }
23} catch (Exception $e) {
24    var_dump((string)$e);
25}
26?>
27--EXPECTF--
28string(%d) "Exception: Foo in %sbug70944.php:%d
29Stack trace:
30#0 {main}"
31string(%d) "Exception: Foo in %sbug70944.php:%d
32Stack trace:
33#0 {main}
34
35Next Exception: Dummy in %sbug70944.php:%d
36Stack trace:
37#0 {main}"
38