diff options
Diffstat (limited to 'ext/opcache/tests/ssa_bug_003.phpt')
| -rw-r--r-- | ext/opcache/tests/ssa_bug_003.phpt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/opcache/tests/ssa_bug_003.phpt b/ext/opcache/tests/ssa_bug_003.phpt new file mode 100644 index 0000000000..2895551c08 --- /dev/null +++ b/ext/opcache/tests/ssa_bug_003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Incorrect elision of return type checks +--FILE-- +<?php + +function test1($x) : callable { + if ($x == 1) { + $c = 'foo'; + } elseif ($x == 2) { + $c = new stdClass; + } else { + $c = [$x => &$x]; + } + return $c; +} + +try { + test1(1); +} catch (Error $e) { + echo "Error: {$e->getMessage()}\n"; +} + +class Foo {} +function test2() : Foo { + $obj = new stdClass; + return $obj; +} + +try { + test2(); +} catch (Error $e) { + echo "Error: {$e->getMessage()}\n"; +} + +?> +--EXPECT-- +Error: Return value of test1() must be callable, string returned +Error: Return value of test2() must be an instance of Foo, instance of stdClass returned |
