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 @@ -2537,12 +2537,26 @@ static zend_always_inline int _zend_update_type_info(
2537
2537
} else if (opline -> opcode == ZEND_ASSIGN_OBJ_OP ) {
2538
2538
/* The return value must also satisfy the property type */
2539
2539
if (prop_info ) {
2540
- tmp &= zend_fetch_prop_type (script , prop_info , NULL );
2540
+ t1 = zend_fetch_prop_type (script , prop_info , NULL );
2541
+ if ((t1 & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_LONG
2542
+ && (tmp & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_DOUBLE ) {
2543
+ /* DOUBLE may be auto-converted to LONG */
2544
+ tmp |= MAY_BE_LONG ;
2545
+ tmp &= ~MAY_BE_DOUBLE ;
2546
+ }
2547
+ tmp &= t1 ;
2541
2548
}
2542
2549
} else if (opline -> opcode == ZEND_ASSIGN_STATIC_PROP_OP ) {
2543
2550
/* The return value must also satisfy the property type */
2544
2551
if (prop_info ) {
2545
- tmp &= zend_fetch_prop_type (script , prop_info , NULL );
2552
+ t1 = zend_fetch_prop_type (script , prop_info , NULL );
2553
+ if ((t1 & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_LONG
2554
+ && (tmp & (MAY_BE_LONG |MAY_BE_DOUBLE )) == MAY_BE_DOUBLE ) {
2555
+ /* DOUBLE may be auto-converted to LONG */
2556
+ tmp |= MAY_BE_LONG ;
2557
+ tmp &= ~MAY_BE_DOUBLE ;
2558
+ }
2559
+ tmp &= t1 ;
2546
2560
}
2547
2561
} else {
2548
2562
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