Skip to content

Commit

Permalink
Fix vimeo#4306 - negating positive-numeric is useless, avoid crash
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug authored and danog committed Jan 29, 2021
1 parent 4f5a3ca commit 01781af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Psalm/Internal/Type/NegatedAssertionReconciler.php
Expand Up @@ -67,6 +67,10 @@ public static function reconcile(
);
}

if ($is_equality && $assertion === 'positive-numeric') {
return $existing_var_type;
}

if (!$is_equality) {
if ($assertion === 'isset') {
if ($existing_var_type->possibly_undefined) {
Expand Down
6 changes: 6 additions & 0 deletions tests/TypeReconciliation/ValueTest.php
Expand Up @@ -775,6 +775,12 @@ function x(?string $foo): void {
if ($foo) {}
}',
],
'allowCheckOnPositiveNumericInverse' => [
'<?php
function foo(int $a): void {
if (false === ($a > 1)){}
}'
],
];
}

Expand Down

0 comments on commit 01781af

Please sign in to comment.