Skip to content

Commit

Permalink
Fix #4011 - prevent mixed assignment in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Aug 18, 2020
1 parent 17ed440 commit 134955a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ private static function reconcilePositiveNumeric(

$failed_reconciliation = 2;

return Type::getMixed();
return Type::getEmpty();
}

/**
Expand Down
14 changes: 13 additions & 1 deletion tests/Loop/WhileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,19 @@ function foo(string $key): array {
return $elements;
}',
]
],
'reconcilePositiveInt' => [
'<?php
$counter = 0;
while (rand(0, 1)) {
if ($counter > 0) {
$counter = $counter - 1;
} else {
$counter = $counter + 1;
}
}'
],
];
}

Expand Down

0 comments on commit 134955a

Please sign in to comment.