diff options
| -rw-r--r-- | ext/opcache/Optimizer/dfa_pass.c | 3 | ||||
| -rw-r--r-- | ext/opcache/tests/iterable_type_optimization.phpt | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 4204f53805..5401c9df6a 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -321,7 +321,8 @@ static inline zend_bool can_elide_return_type_check( return 0; } - if (ZEND_TYPE_CODE(info->type) == IS_CALLABLE) { + /* These types are not represented exactly */ + if (ZEND_TYPE_CODE(info->type) == IS_CALLABLE || ZEND_TYPE_CODE(info->type) == IS_ITERABLE) { return 0; } diff --git a/ext/opcache/tests/iterable_type_optimization.phpt b/ext/opcache/tests/iterable_type_optimization.phpt new file mode 100644 index 0000000000..b5247cd69c --- /dev/null +++ b/ext/opcache/tests/iterable_type_optimization.phpt @@ -0,0 +1,17 @@ +--TEST-- +Don't optimize object -> iterable +--FILE-- +<?php + +function test(object $arg): iterable { + return $arg; +} +test(new stdClass); + +?> +--EXPECTF-- +Fatal error: Uncaught TypeError: Return value of test() must be iterable, object returned in %s:%d +Stack trace: +#0 %s(%d): test(Object(stdClass)) +#1 {main} + thrown in %s on line %d |
