Skip to content

Commit

Permalink
Fix range() return type inference for undef operand
Browse files Browse the repository at this point in the history
This results in a long range.
  • Loading branch information
nikic committed Sep 21, 2021
1 parent 3733750 commit a846547
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Zend/Optimizer/zend_func_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa
|| (t3 & (MAY_BE_DOUBLE|MAY_BE_STRING))) {
tmp |= MAY_BE_ARRAY_OF_DOUBLE;
}
if ((t1 & (MAY_BE_ANY-(MAY_BE_STRING|MAY_BE_DOUBLE))) && (t2 & (MAY_BE_ANY-(MAY_BE_STRING|MAY_BE_DOUBLE)))) {
if ((t1 & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_STRING|MAY_BE_DOUBLE)))
&& (t2 & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_STRING|MAY_BE_DOUBLE)))) {
if ((t3 & MAY_BE_ANY) != MAY_BE_DOUBLE) {
tmp |= MAY_BE_ARRAY_OF_LONG;
}
Expand Down
3 changes: 3 additions & 0 deletions ext/opcache/tests/invalid_array_key_type.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ function test(\SplObjectStorage $definitions = null) {
function test2() {
$a[[]] = $undef;
}
function test3() {
foreach (range(0, $undef) as $v) { }
}

?>
===DONE===
Expand Down

0 comments on commit a846547

Please sign in to comment.