diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index c426694d9..e55661873 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -1026,6 +1026,7 @@ class AssertionReconciler extends Reconciler foreach ($existing_var_atomic_types as $atomic_key => $atomic_type) { if ($atomic_key !== $assertion && !($atomic_type instanceof TPositiveInt && $value > 0) + && !($atomic_type instanceof TIntRange && $atomic_type->contains($value)) ) { $existing_var_type->removeType($atomic_key); $did_remove_type = true; diff --git a/tests/IntRangeTest.php b/tests/IntRangeTest.php index 8397ba181..5b7cf913e 100644 --- a/tests/IntRangeTest.php +++ b/tests/IntRangeTest.php @@ -669,6 +669,18 @@ class IntRangeTest extends TestCase '$length===' => 'int<1, 7>', ], ], + 'literalEquality' => [ + ' 16) { + throw new exception(""); + } + + assert($length === 1); + ', + ], ]; }