Skip to content

Commit 5a77870

Browse files
committed
Fixed empty array inference
1 parent 0734a12 commit 5a77870

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,9 @@ static zend_always_inline zend_result _zend_update_type_info(
26742674
}
26752675
}
26762676
if (opline->extended_value == IS_ARRAY) {
2677+
if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL)) {
2678+
tmp |= MAY_BE_ARRAY_EMPTY;
2679+
}
26772680
if (t1 & MAY_BE_ARRAY) {
26782681
tmp |= t1 & (MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF);
26792682
}
@@ -3387,6 +3390,9 @@ static zend_always_inline zend_result _zend_update_type_info(
33873390
arr_type = RES_USE_INFO();
33883391
}
33893392
tmp = MAY_BE_RC1|MAY_BE_ARRAY|arr_type;
3393+
if (opline->opcode == ZEND_INIT_ARRAY && opline->op1_type == IS_UNUSED) {
3394+
tmp |= MAY_BE_ARRAY_EMPTY;
3395+
}
33903396
if (opline->op1_type != IS_UNUSED
33913397
&& (opline->op2_type == IS_UNUSED
33923398
|| (t2 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_RESOURCE|MAY_BE_STRING)))) {

0 commit comments

Comments
 (0)