Skip to content

Commit f1fc58e

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix type inference
2 parents b1b79c7 + 3f1e1b9 commit f1fc58e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,10 +3251,11 @@ static zend_always_inline int _zend_update_type_info(
32513251
tmp |= t1 & (MAY_BE_RC1|MAY_BE_RCN);
32523252
}
32533253
}
3254-
if (opline->opcode == ZEND_FETCH_DIM_RW
3254+
if ((key_type & (MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING))
3255+
&& (opline->opcode == ZEND_FETCH_DIM_RW
32553256
|| opline->opcode == ZEND_FETCH_DIM_W
32563257
|| opline->opcode == ZEND_FETCH_DIM_FUNC_ARG
3257-
|| opline->opcode == ZEND_FETCH_LIST_W) {
3258+
|| opline->opcode == ZEND_FETCH_LIST_W)) {
32583259
j = ssa_vars[ssa_op->result_def].use_chain;
32593260
if (j < 0) {
32603261
/* no uses */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Type inference 006: FETCH_DIM_W with invalid key type
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function y() {
10+
$obj=new y;
11+
u($y[$obj]);
12+
}
13+
?>
14+
DONE
15+
--EXPECT--
16+
DONE

0 commit comments

Comments
 (0)