diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-19 17:22:28 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-19 17:22:28 +0200 |
| commit | 5bee9c9062642cb34cc1c94bda5980960fad6006 (patch) | |
| tree | e0d51cf5156f70ae813cbb4cbff5ab16bbe275f4 | |
| parent | 8a599c7b743c0bb4c15b34ce288f17eee90a23b6 (diff) | |
| parent | 85e7668129a5368bf58d9987a58ef562742b7314 (diff) | |
| download | php-git-5bee9c9062642cb34cc1c94bda5980960fad6006.tar.gz | |
Merge branch 'PHP-7.3' into PHP-7.4
| -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 |
