mirror of
https://github.com/php/php-src.git
synced 2025-01-24 04:33:39 +08:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix ASSIGN_DIM result inference with typed refs Remove outdated code in ASSIGN_DIM type inference
This commit is contained in:
commit
8b7874b262
@ -2810,31 +2810,21 @@ static zend_always_inline zend_result _zend_update_type_info(
|
||||
if (t1 & MAY_BE_STRING) {
|
||||
tmp |= MAY_BE_STRING;
|
||||
}
|
||||
if (t1 & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_STRING)) {
|
||||
if (t1 & (MAY_BE_ARRAY|MAY_BE_FALSE|MAY_BE_NULL|MAY_BE_UNDEF)) {
|
||||
tmp |= (OP1_DATA_INFO() & (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF));
|
||||
|
||||
if (OP1_DATA_INFO() & MAY_BE_UNDEF) {
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
if (opline->op2_type == IS_UNUSED) {
|
||||
/* When appending to an array and the LONG_MAX key is already used
|
||||
* null will be returned. */
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
if (t2 & (MAY_BE_ARRAY | MAY_BE_OBJECT)) {
|
||||
/* Arrays and objects cannot be used as keys. */
|
||||
tmp |= MAY_BE_NULL;
|
||||
}
|
||||
if (t1 & (MAY_BE_ANY - (MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY))) {
|
||||
/* undef, null and false are implicitly converted to array, anything else
|
||||
* results in a null return value. */
|
||||
tmp |= MAY_BE_NULL;
|
||||
if (t1 & MAY_BE_ARRAY_OF_REF) {
|
||||
/* A scalar type conversion may occur when assigning to a typed reference. */
|
||||
tmp |= MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING;
|
||||
}
|
||||
}
|
||||
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
|
||||
if (t1 & MAY_BE_OBJECT) {
|
||||
tmp |= MAY_BE_REF;
|
||||
}
|
||||
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
|
||||
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
|
||||
}
|
||||
if ((ssa_op+1)->op1_def >= 0) {
|
||||
@ -2939,9 +2929,9 @@ static zend_always_inline zend_result _zend_update_type_info(
|
||||
}
|
||||
if (ssa_op->result_def >= 0) {
|
||||
if (tmp & MAY_BE_REF) {
|
||||
/* Assignment to typed reference may change type.
|
||||
* Be conservative and don't assume anything. */
|
||||
tmp = MAY_BE_RC1|MAY_BE_RCN|MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF;
|
||||
/* A scalar type conversion may occur when assigning to a typed reference. */
|
||||
tmp &= ~MAY_BE_REF;
|
||||
tmp |= MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_RC1|MAY_BE_RCN;
|
||||
}
|
||||
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
|
||||
COPY_SSA_OBJ_TYPE(ssa_op->op2_use, ssa_op->result_def);
|
||||
|
@ -11,8 +11,16 @@ function test() {
|
||||
$ref =& $obj->prop;
|
||||
var_dump($ref = 0);
|
||||
}
|
||||
function test2() {
|
||||
$obj = new Test;
|
||||
$ary = [];
|
||||
$ary[0] =& $obj->prop;
|
||||
var_dump($ary[0] = 0);
|
||||
}
|
||||
test();
|
||||
test2();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "0"
|
||||
string(1) "0"
|
||||
|
Loading…
Reference in New Issue
Block a user