File tree 2 files changed +42
-2
lines changed 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -2569,12 +2569,26 @@ static zend_always_inline zend_result _zend_update_type_info(
2569
2569
} else if (opline -> opcode == ZEND_ASSIGN_OBJ_OP ) {
2570
2570
/* The return value must also satisfy the property type */
2571
2571
if (prop_info ) {
2572
- tmp &= zend_fetch_prop_type (script , prop_info , NULL );
2572
+ t1 = zend_fetch_prop_type (script , prop_info , NULL );
2573
+ if ((t1 & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_LONG
2574
+ && (tmp & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_DOUBLE ) {
2575
+ /* DOUBLE may be auto-converted to LONG */
2576
+ tmp |= MAY_BE_LONG ;
2577
+ tmp &= ~MAY_BE_DOUBLE ;
2578
+ }
2579
+ tmp &= t1 ;
2573
2580
}
2574
2581
} else if (opline -> opcode == ZEND_ASSIGN_STATIC_PROP_OP ) {
2575
2582
/* The return value must also satisfy the property type */
2576
2583
if (prop_info ) {
2577
- tmp &= zend_fetch_prop_type (script , prop_info , NULL );
2584
+ t1 = zend_fetch_prop_type (script , prop_info , NULL );
2585
+ if ((t1 & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_LONG
2586
+ && (tmp & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_DOUBLE ) {
2587
+ /* DOUBLE may be auto-converted to LONG */
2588
+ tmp |= MAY_BE_LONG ;
2589
+ tmp &= ~MAY_BE_DOUBLE ;
2590
+ }
2591
+ tmp &= t1 ;
2578
2592
}
2579
2593
} else {
2580
2594
if (tmp & MAY_BE_REF ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ JIT ASSIGN_OBJ_OP: invalid type inference
3
+ --INI--
4
+ opcache.enable=1
5
+ opcache.enable_cli=1
6
+ opcache.file_update_protection=0
7
+ opcache.jit_buffer_size=1M
8
+ --FILE--
9
+ <?php
10
+ class Foo {
11
+ public int $ bar =0 ;
12
+ function __construct () {
13
+ try {
14
+ +$ this ->bar += 1.3 ;
15
+ } catch (y ) {
16
+ }
17
+ }
18
+ }
19
+ var_dump (new Foo );
20
+ ?>
21
+ --EXPECTF--
22
+ Deprecated: Implicit conversion from float 1.3 to int loses precision in %sassign_obj_op_003.php on line 6
23
+ object(Foo)#1 (1) {
24
+ ["bar"]=>
25
+ int(1)
26
+ }
You can’t perform that action at this time.
0 commit comments