Skip to content

Commit 2f3538c

Browse files
committed
Improved type inference for FE_FETCH_R
1 parent 56c18c4 commit 2f3538c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,12 +3210,18 @@ static zend_always_inline int _zend_update_type_info(
32103210
break;
32113211
case ZEND_FE_FETCH_R:
32123212
case ZEND_FE_FETCH_RW:
3213-
tmp = t2 & MAY_BE_REF;
3213+
tmp = 0;
3214+
if (opline->op2_type == IS_CV) {
3215+
tmp = t2 & MAY_BE_REF;
3216+
}
32143217
if (t1 & MAY_BE_OBJECT) {
32153218
if (opline->opcode == ZEND_FE_FETCH_RW) {
32163219
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
32173220
} else {
3218-
tmp |= MAY_BE_REF | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
3221+
tmp |= MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
3222+
if (opline->op2_type != IS_CV) {
3223+
tmp |= MAY_BE_REF;
3224+
}
32193225
}
32203226
}
32213227
if (t1 & MAY_BE_ARRAY) {
@@ -3228,6 +3234,9 @@ static zend_always_inline int _zend_update_type_info(
32283234
}
32293235
if (t1 & MAY_BE_ARRAY_OF_REF) {
32303236
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
3237+
if (opline->op2_type != IS_CV) {
3238+
tmp |= MAY_BE_REF;
3239+
}
32313240
} else if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
32323241
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
32333242
}

0 commit comments

Comments
 (0)