File tree 2 files changed +27
-0
lines changed 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -2545,6 +2545,7 @@ static zend_always_inline zend_result _zend_update_type_info(
2545
2545
* code may assume that operands have at least one type. */
2546
2546
if (!(t1 & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS ))
2547
2547
|| !(t2 & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS ))
2548
+ || (ssa_op -> result_use >= 0 && !(RES_USE_INFO () & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS )))
2548
2549
|| ((opline -> opcode == ZEND_ASSIGN_DIM_OP
2549
2550
|| opline -> opcode == ZEND_ASSIGN_OBJ_OP
2550
2551
|| opline -> opcode == ZEND_ASSIGN_STATIC_PROP_OP
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT
3
+ --INI--
4
+ opcache.enable=1
5
+ opcache.enable_cli=1
6
+ --EXTENSIONS--
7
+ opcache
8
+ --FILE--
9
+ <?php
10
+ function test ()
11
+ {
12
+ $ bool_or_int = true ;
13
+ while (a ()) {
14
+ if ($ bool_or_int !== true ) {
15
+ // The following line triggers narrowing during type inference of ZEND_ADD_ARRAY_ELEMENT.
16
+ $ string_key = "a " ;
17
+ $ array = ["bool_or_int " => $ bool_or_int , $ string_key => 123 ];
18
+ }
19
+
20
+ $ bool_or_int = 0 ;
21
+ }
22
+ }
23
+ ?>
24
+ DONE
25
+ --EXPECT--
26
+ DONE
You can’t perform that action at this time.
0 commit comments