Skip to content

Commit 2067388

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix range() return type inference for undef operand
2 parents e05f366 + a846547 commit 2067388

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Zend/Optimizer/zend_func_info.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa
7575
|| (t3 & (MAY_BE_DOUBLE|MAY_BE_STRING))) {
7676
tmp |= MAY_BE_ARRAY_OF_DOUBLE;
7777
}
78-
if ((t1 & (MAY_BE_ANY-(MAY_BE_STRING|MAY_BE_DOUBLE))) && (t2 & (MAY_BE_ANY-(MAY_BE_STRING|MAY_BE_DOUBLE)))) {
78+
if ((t1 & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_STRING|MAY_BE_DOUBLE)))
79+
&& (t2 & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_STRING|MAY_BE_DOUBLE)))) {
7980
if ((t3 & MAY_BE_ANY) != MAY_BE_DOUBLE) {
8081
tmp |= MAY_BE_ARRAY_OF_LONG;
8182
}

ext/opcache/tests/invalid_array_key_type.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ function test(\SplObjectStorage $definitions = null) {
1616
function test2() {
1717
$a[[]] = $undef;
1818
}
19+
function test3() {
20+
foreach (range(0, $undef) as $v) { }
21+
}
1922

2023
?>
2124
===DONE===

0 commit comments

Comments
 (0)