diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php index de698bc26..f62616160 100644 --- a/src/Psalm/Context.php +++ b/src/Psalm/Context.php @@ -463,10 +463,7 @@ class Context $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 e62686f64..5629a4a21 100644 --- a/tests/Loop/WhileTest.php +++ b/tests/Loop/WhileTest.php @@ -585,6 +585,44 @@ class WhileTest extends \Psalm\Tests\TestCase } }' ], + 'ifNestedInsideLoop' => [ + ' [ + '