Skip to content

Commit 7ea3b19

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-8074: Wrong type inference of range() result
2 parents fb70460 + ef80dcb commit 7ea3b19

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
. Fixed bug GH-8083 Segfault when dumping uncalled fake closure with static
99
variables. (ilutov)
1010
. Fixed bug GH-7958 (Nested CallbackFilterIterator is leaking memory). (cmb)
11+
. Fixed bug GH-8074 (Wrong type inference of range() result). (cmb)
1112

1213
- GD:
1314
. Fixed libpng warning when loading interlaced images. (Brett)

Zend/Optimizer/zend_func_info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +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_UNDEF)-(MAY_BE_STRING|MAY_BE_DOUBLE)))
79-
&& (t2 & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_STRING|MAY_BE_DOUBLE)))) {
78+
if ((t1 & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_DOUBLE))
79+
&& (t2 & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_DOUBLE))) {
8080
if ((t3 & MAY_BE_ANY) != MAY_BE_DOUBLE) {
8181
tmp |= MAY_BE_ARRAY_OF_LONG;
8282
}

ext/opcache/tests/opt/gh8074.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-8074 (Wrong type inference of range() result)
3+
--FILE--
4+
<?php
5+
function test() {
6+
$array = range(1, "2");
7+
8+
foreach ($array as $i) {
9+
var_dump($i + 1);
10+
}
11+
}
12+
13+
test();
14+
?>
15+
--EXPECT--
16+
int(2)
17+
int(3)

0 commit comments

Comments
 (0)