Skip to content

Commit 983a4fc

Browse files
committed
Fix ASSIGN_STATIC_PROP_REF type inference
We were not inferring anything for the ASSIGN_STATIC_PROP_REF result type at all, leaving it as an empty type. In the test case this results in a live range being incorrectly eliminated, but this could break in all kinds of other ways as well..
1 parent 7708797 commit 983a4fc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,6 +2938,9 @@ static zend_always_inline int _zend_update_type_info(
29382938
}
29392939
break;
29402940
case ZEND_ASSIGN_STATIC_PROP_REF:
2941+
if (ssa_op->result_def >= 0) {
2942+
UPDATE_SSA_TYPE(MAY_BE_REF, ssa_op->result_def);
2943+
}
29412944
if ((opline+1)->op1_type == IS_CV) {
29422945
opline++;
29432946
ssa_op++;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
ASSIGN_STATIC_PROP_REF result should have live range
3+
--FILE--
4+
<?php
5+
class Test {
6+
public static $prop;
7+
}
8+
Test::$prop =& $v + UNDEF;
9+
?>
10+
--EXPECTF--
11+
Fatal error: Uncaught Error: Undefined constant "UNDEF" in %s:%d
12+
Stack trace:
13+
#0 {main}
14+
thrown in %s on line %d

0 commit comments

Comments
 (0)