function foo() {
try { return str_repeat("a", 2); }
- finally { return true; }
+ finally { return str_repeat("b", 2); }
}
var_dump(foo());
?>
--EXPECT--
-string(3) "bar"
+string(2) "bb"
--- /dev/null
+--TEST--
+Bug #72213 (Finally leaks on nested exceptions)
+--XFAIL--
+See https://bugs.php.net/bug.php?id=72213
+--FILE--
+<?php
+function test() {
+ try {
+ throw new Exception('a');
+ } finally {
+ try {
+ throw new Exception('b');
+ } finally {
+ }
+ }
+}
+
+try {
+ test();
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+ var_dump($e->getPrevious()->getMessage());
+}
+?>
+--EXPECT--
+string(1) "b"
+string(1) "a"
--- /dev/null
+--TEST--
+Bug #72213 (Finally leaks on nested exceptions)
+--FILE--
+<?php
+function test() {
+ try {
+ throw new Exception(1);
+ } finally {
+ try {
+ try {
+ throw new Exception(2);
+ } finally {
+ }
+ } catch (Exception $e) {
+ }
+ }
+}
+
+try {
+ test();
+} catch (Exception $e) {
+ echo "caught {$e->getMessage()}\n";
+}
+--EXPECT--
+caught 1