mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix type inference
This commit is contained in:
commit
ea37abd412
2 changed files with 42 additions and 2 deletions
|
@ -2569,12 +2569,26 @@ static zend_always_inline zend_result _zend_update_type_info(
|
|||
} else if (opline->opcode == ZEND_ASSIGN_OBJ_OP) {
|
||||
/* The return value must also satisfy the property type */
|
||||
if (prop_info) {
|
||||
tmp &= zend_fetch_prop_type(script, prop_info, NULL);
|
||||
t1 = zend_fetch_prop_type(script, prop_info, NULL);
|
||||
if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG
|
||||
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) {
|
||||
/* DOUBLE may be auto-converted to LONG */
|
||||
tmp |= MAY_BE_LONG;
|
||||
tmp &= ~MAY_BE_DOUBLE;
|
||||
}
|
||||
tmp &= t1;
|
||||
}
|
||||
} else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP) {
|
||||
/* The return value must also satisfy the property type */
|
||||
if (prop_info) {
|
||||
tmp &= zend_fetch_prop_type(script, prop_info, NULL);
|
||||
t1 = zend_fetch_prop_type(script, prop_info, NULL);
|
||||
if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG
|
||||
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) {
|
||||
/* DOUBLE may be auto-converted to LONG */
|
||||
tmp |= MAY_BE_LONG;
|
||||
tmp &= ~MAY_BE_DOUBLE;
|
||||
}
|
||||
tmp &= t1;
|
||||
}
|
||||
} else {
|
||||
if (tmp & MAY_BE_REF) {
|
||||
|
|
26
ext/opcache/tests/jit/assign_obj_op_003.phpt
Normal file
26
ext/opcache/tests/jit/assign_obj_op_003.phpt
Normal file
|
@ -0,0 +1,26 @@
|
|||
--TEST--
|
||||
JIT ASSIGN_OBJ_OP: invalid type inference
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.file_update_protection=0
|
||||
opcache.jit_buffer_size=1M
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo {
|
||||
public int $bar=0;
|
||||
function __construct() {
|
||||
try {
|
||||
+$this->bar += 1.3;
|
||||
} catch(y) {
|
||||
}
|
||||
}
|
||||
}
|
||||
var_dump(new Foo);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicit conversion from float 1.3 to int loses precision in %sassign_obj_op_003.php on line 6
|
||||
object(Foo)#1 (1) {
|
||||
["bar"]=>
|
||||
int(1)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue