diff --git a/src/Psalm/Checker/Statements/Block/SwitchChecker.php b/src/Psalm/Checker/Statements/Block/SwitchChecker.php index 84cf2c60d..718a7b62a 100644 --- a/src/Psalm/Checker/Statements/Block/SwitchChecker.php +++ b/src/Psalm/Checker/Statements/Block/SwitchChecker.php @@ -180,8 +180,6 @@ class SwitchChecker if ($possibly_redefined_vars === null) { $possibly_redefined_vars = $case_redefined_vars; } else { - $possibly_redefined_vars = []; - foreach ($case_redefined_vars as $var_id => $type) { if (!isset($possibly_redefined_vars[$var_id])) { $possibly_redefined_vars[$var_id] = $type; diff --git a/tests/SwitchTypeTest.php b/tests/SwitchTypeTest.php index 23c0ff3a2..91c63d26a 100644 --- a/tests/SwitchTypeTest.php +++ b/tests/SwitchTypeTest.php @@ -201,6 +201,28 @@ class SwitchTypeTest extends TestCase throw new RuntimeException("none found"); }', ], + 'switchBools' => [ + ' [ + '$x' => 'bool', + '$y' => 'bool', + ], + ], ]; }