diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index 2a112e94e..117890be3 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -181,6 +181,7 @@ class NegatedAssertionReconciler extends Reconciler )); } elseif ($assertion_type instanceof TInt && isset($existing_var_type->getAtomicTypes()['array-key']) + && !$is_equality ) { $existing_var_type->removeType('array-key'); $existing_var_type->addType(new TString); diff --git a/tests/IntRangeTest.php b/tests/IntRangeTest.php index 491d81d98..143138166 100644 --- a/tests/IntRangeTest.php +++ b/tests/IntRangeTest.php @@ -800,6 +800,20 @@ class IntRangeTest extends TestCase ], ], + 'arraykeyCanBeRange' => [ + 'code' => '