mirror of
https://github.com/php/php-src.git
synced 2025-01-09 12:34:14 +08:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix array cast type inference wrt packed arrays
This commit is contained in:
commit
aa2f8311c6
@ -2556,8 +2556,8 @@ static zend_always_inline zend_result _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_NULL)) << MAY_BE_ARRAY_SHIFT) | ((t1 & (MAY_BE_ANY - MAY_BE_NULL)) ? MAY_BE_ARRAY_PACKED : 0);
|
||||
} else if (t1 & (MAY_BE_ANY - MAY_BE_NULL)) {
|
||||
tmp |= ((t1 & (MAY_BE_ANY - MAY_BE_NULL)) << MAY_BE_ARRAY_SHIFT) | ((t1 & MAY_BE_NULL) ? MAY_BE_ARRAY_KEY_LONG : MAY_BE_ARRAY_PACKED);
|
||||
}
|
||||
}
|
||||
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
|
||||
|
21
ext/opcache/tests/jit/cast_002.phpt
Normal file
21
ext/opcache/tests/jit/cast_002.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
JIT CAST: 002
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.file_update_protection=0
|
||||
opcache.jit_buffer_size=1M
|
||||
--FILE--
|
||||
<?php
|
||||
function test(?int $i) {
|
||||
$a = (array) $i;
|
||||
$a[-1] = 1;
|
||||
var_dump($a);
|
||||
}
|
||||
test(null);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[-1]=>
|
||||
int(1)
|
||||
}
|
Loading…
Reference in New Issue
Block a user