Skip to content

Commit

Permalink
Fixed bug #75608 ("Narrowing occurred during type inference" error)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Dec 4, 2017
1 parent 1da28c5 commit 5934bff
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ PHP NEWS
requests). (Remi)

- Opcache:
. Fixed bug #75608 ("Narrowing occurred during type inference" error).
(Laruence, Dmitry)
. Fixed bug #75570 ("Narrowing occurred during type inference" error).
(Dmitry)

Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -2928,7 +2928,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
break;
case ZEND_FE_FETCH_R:
case ZEND_FE_FETCH_RW:
tmp = (t2 & MAY_BE_REF);
tmp = t2;
if (t1 & MAY_BE_OBJECT) {
if (opline->opcode == ZEND_FE_FETCH_RW) {
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
Expand All @@ -2953,7 +2953,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
}
UPDATE_SSA_TYPE(tmp, ssa_ops[i].op2_def);
if (ssa_ops[i].result_def >= 0) {
tmp = 0;
tmp = (ssa_ops[i].result_use >= 0) ? RES_USE_INFO() : 0;
if (t1 & MAY_BE_OBJECT) {
tmp |= MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
}
Expand Down
33 changes: 33 additions & 0 deletions ext/opcache/tests/bug75608.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
Bug #75608 ("Narrowing occurred during type inference" error)
--FILE--
<?php
class ReactionRatingService
{
public function calculateBoostPoints()
{
while ($reaction = $reactions) {
$reactionRatings = $this->validFunction();

$totalWeight = 0;
$runningScore = 0;
$queue = [];
foreach ($reactionRatings as $ratingData) {
if ($runningScore != $reaction['Score']) {
if ( ! $ratingData['BoostEarned']) {
$queue[] = $ratingData['UserID'];
}
} else {
foreach ($queue as $userId) {
$userBoostPointsRecalculate[$userId][] = $reaction['ID'];
}
}
$totalWeight += $ratingData['Weight'];
}
}
}
}
?>
OK
--EXPECT--
OK

0 comments on commit 5934bff

Please sign in to comment.