1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fixed GH-8251: Narrowing occurred during type inference of ZEND_FETCH_DIM_W
This commit is contained in:
Dmitry Stogov
2023-11-28 23:33:45 +03:00
2 changed files with 25 additions and 3 deletions

View File

@@ -3689,9 +3689,7 @@ static zend_always_inline zend_result _zend_update_type_info(
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
} else {
/* invalid key type */
tmp = (tmp & (MAY_BE_RC1|MAY_BE_RCN|MAY_BE_ARRAY)) |
(t1 & ~(MAY_BE_RC1|MAY_BE_RCN|MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE));
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
return SUCCESS;
}
COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def);
}

View File

@@ -0,0 +1,24 @@
--TEST--
Type inference 023: FETCH_DIM_W
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--FILE--
<?php
function foo($data): array {
$a = [];
$n = -1;
foreach ($data as $d) {
if ($n >= 0) {
$a[$n]->x = 2;
}
$n++;
$a[$n] = new stdClass();
$a[$n]->x = 1;
}
}
?>
DONE
--EXPECT--
DONE