diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php index de698bc26a2..f6261616077 100644 --- a/src/Psalm/Context.php +++ b/src/Psalm/Context.php @@ -463,10 +463,7 @@ public function getRedefinedVars(array $new_vars_in_scope, bool $include_new_var $new_type = $new_vars_in_scope[$var_id]; - if (!$this_type->isEmpty() - && !$new_type->isEmpty() - && !$this_type->equals($new_type) - ) { + if (!$this_type->equals($new_type)) { $redefined_vars[$var_id] = $this_type; } } diff --git a/tests/Loop/WhileTest.php b/tests/Loop/WhileTest.php index e62686f64ef..5629a4a2130 100644 --- a/tests/Loop/WhileTest.php +++ b/tests/Loop/WhileTest.php @@ -585,6 +585,44 @@ public function alter() : void { } }' ], + 'ifNestedInsideLoop' => [ + ' [ + '