File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -2530,7 +2530,8 @@ static zend_always_inline int _zend_update_type_info(
2530
2530
* unreachable code. Propagate the empty result early, so that that the following
2531
2531
* code may assume that operands have at least one type. */
2532
2532
if (!(t1 & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS ))
2533
- || !(t2 & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS ))) {
2533
+ || !(t2 & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS ))
2534
+ || (ssa_op -> result_use >= 0 && !(RES_USE_INFO () & (MAY_BE_ANY |MAY_BE_UNDEF |MAY_BE_CLASS )))) {
2534
2535
tmp = 0 ;
2535
2536
if (ssa_op -> result_def >= 0 && !(ssa_var_info [ssa_op -> result_def ].type & MAY_BE_REF )) {
2536
2537
UPDATE_SSA_TYPE (tmp , ssa_op -> result_def );
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