Skip to content

Commit c151e9b

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix type inference
2 parents f098193 + c852e0f commit c151e9b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,9 @@ static zend_always_inline zend_result _zend_update_type_info(
33993399
opline->opcode != ZEND_FETCH_DIM_R && opline->opcode != ZEND_FETCH_DIM_IS
34003400
&& opline->opcode != ZEND_FETCH_LIST_R,
34013401
opline->op2_type == IS_UNUSED);
3402+
if (opline->opcode == ZEND_FETCH_DIM_FUNC_ARG && (t1 & (MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_RESOURCE))) {
3403+
tmp |= MAY_BE_NULL;
3404+
}
34023405
if (opline->opcode == ZEND_FETCH_DIM_IS && (t1 & MAY_BE_STRING)) {
34033406
tmp |= MAY_BE_NULL;
34043407
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT FETCH_DIM_FUNC_ARG: 002
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
new class(true[""]) {
13+
}
14+
?>
15+
DONE
16+
--EXPECTF--
17+
Warning: Trying to access array offset on value of type bool in %sfetch_dim_func_arg_002.php on line 2
18+
DONE

0 commit comments

Comments
 (0)