Skip to content

Commit 6f6289c

Browse files
committed
Avoid new SSA var for ASSIGN_OBJ_REF without RC inference
Previously, this variable was necessary because of auto-vivification on UNDEF/null/false. It's now only used for RC inference, as auto-vivification has been removed. This implicitly solves an inference problem for $obj->bar &= $obj; where we get a new variable for both literal references to $obj, with the first one getting the RCn flag, and the second one getting the MAY_BE_REFERENCE flag. Thus, the first variable will be missing the reference type, causing a false-positive type inference warning. If we want to verify RC inference at some point we'll need a better solution. Closes GH-13233
1 parent 7040e8e commit 6f6289c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,7 @@ static zend_always_inline zend_result _zend_update_type_info(
31573157
}
31583158
break;
31593159
case ZEND_ASSIGN_OBJ_REF:
3160-
if (opline->op1_type == IS_CV) {
3160+
if (opline->op1_type == IS_CV && ssa_op->op1_def >= 0) {
31613161
tmp = t1;
31623162
if (tmp & MAY_BE_OBJECT) {
31633163
tmp |= MAY_BE_RC1 | MAY_BE_RCN;

Zend/Optimizer/zend_ssa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
607607
}
608608
break;
609609
case ZEND_ASSIGN_OBJ_REF:
610-
if (opline->op1_type == IS_CV) {
610+
if ((build_flags & ZEND_SSA_RC_INFERENCE) && opline->op1_type == IS_CV) {
611611
ssa_ops[k].op1_def = ssa_vars_count;
612612
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
613613
ssa_vars_count++;

0 commit comments

Comments
 (0)