Skip to content

Commit 2fa69a8

Browse files
committed
Infer value is not undef within foreach
I discovered that opcache infers that the variable can be undefined within the loop body (or any types prior to the loop) This seems to be unnecessary - the sources of blocks outside of the loop body include both FE_FETCH_R and FE_FETCH_RW.
1 parent 2ede8db commit 2fa69a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3285,7 +3285,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
32853285
break;
32863286
case ZEND_FE_FETCH_R:
32873287
case ZEND_FE_FETCH_RW:
3288-
tmp = t2;
3288+
tmp = t2 & MAY_BE_REF;
32893289
if (t1 & MAY_BE_OBJECT) {
32903290
if (opline->opcode == ZEND_FE_FETCH_RW) {
32913291
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;

0 commit comments

Comments
 (0)