diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index d8f82e87b24..c2a30c350ac 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2491,6 +2491,10 @@ static zend_always_inline int _zend_update_type_info( tmp |= MAY_BE_RC1 | MAY_BE_RCN; } else { tmp |= MAY_BE_RC1; + if (opline->extended_value == IS_ARRAY + && (t1 & (MAY_BE_UNDEF|MAY_BE_NULL))) { + tmp |= MAY_BE_RCN; + } } } if (opline->extended_value == IS_ARRAY) { @@ -2500,7 +2504,7 @@ static zend_always_inline int _zend_update_type_info( if (t1 & MAY_BE_OBJECT) { tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; } else { - tmp |= ((t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT) | ((t1 & MAY_BE_ANY) ? MAY_BE_ARRAY_PACKED : 0); + tmp |= ((t1 & (MAY_BE_ANY - MAY_BE_NULL)) << MAY_BE_ARRAY_SHIFT) | ((t1 & (MAY_BE_ANY - MAY_BE_NULL)) ? MAY_BE_ARRAY_PACKED : 0); } } UPDATE_SSA_TYPE(tmp, ssa_op->result_def); diff --git a/ext/opcache/tests/jit/cast_001.phpt b/ext/opcache/tests/jit/cast_001.phpt new file mode 100644 index 00000000000..aee69eafad1 --- /dev/null +++ b/ext/opcache/tests/jit/cast_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +JIT CAST: 001 +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.jit=1205 +;opcache.jit_debug=1 +--EXTENSIONS-- +opcache +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + int(42) +}