summaryrefslogtreecommitdiff
path: root/Zend/tests/return_types/029.phpt
blob: c854456a6b337eee5ad69c70367d3897ac61c259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--TEST--
Return types must not double free loop variables
--FILE--
<?php

function foo(): string {
	foreach ([new stdClass] as $class) {
		try {
			return $class; // invalid return type
		} catch (TypeError $e) {
			return "BAG!";
		}
	}
}
try {
	print foo();
} catch (TypeError $e) {
	print "no leak or segfault";
}
?>
--EXPECT--
no leak or segfault