mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed incorrect type inference for "(array)$null".
This commit is contained in:
@@ -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);
|
||||
|
||||
25
ext/opcache/tests/jit/cast_001.phpt
Normal file
25
ext/opcache/tests/jit/cast_001.phpt
Normal file
@@ -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--
|
||||
<?php
|
||||
function foo (int $x = null) {
|
||||
$a = (array)$x;
|
||||
$a[] = 42;
|
||||
var_dump($a);
|
||||
}
|
||||
foo(null);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(42)
|
||||
}
|
||||
Reference in New Issue
Block a user