diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index c1b377db5d2..44adb58dfb2 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -80,6 +80,7 @@ use function count; use function explode; use function get_class; +use function is_int; use function min; use function strlen; use function strpos; @@ -2000,7 +2001,7 @@ private static function reconcileIsGreaterThan( $existing_var_type->addType(new TIntRange($assertion_value, $atomic_type->value)); } }*/ - } elseif ($atomic_type instanceof TInt) { + } elseif ($atomic_type instanceof TInt && is_int($assertion_value)) { $redundant = false; $existing_var_type->removeType($atomic_type->getKey()); $existing_var_type->addType(new TIntRange($assertion_value, null)); diff --git a/tests/IntRangeTest.php b/tests/IntRangeTest.php index 1d14c6d7840..c7c09ae2d92 100644 --- a/tests/IntRangeTest.php +++ b/tests/IntRangeTest.php @@ -1017,6 +1017,19 @@ function bar(int $_a, int $_b): void {} } ', ], + 'rangeOverflow' => [ + 'code' => ' [ + '$z' => 'int|null', + ], + ], ]; }