Skip to content
Permalink
Browse files

Overwrite var when try exits

  • Loading branch information...
muglug committed Jul 7, 2019
1 parent cd715a6 commit 30ecde22723758176af09cd54af3dd4b2b26328b
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
@@ -368,15 +368,15 @@ function ($fq_catch_class) use ($codebase) {
if ($catch_actions[$i] !== [ScopeAnalyzer::ACTION_END]) {
foreach ($catch_context->vars_in_scope as $var_id => $type) {
if (isset($context->vars_in_scope[$var_id])
if ($stmt_control_actions === [ScopeAnalyzer::ACTION_END]) {
$context->vars_in_scope[$var_id] = $type;
} elseif (isset($context->vars_in_scope[$var_id])
&& $context->vars_in_scope[$var_id]->getId() !== $type->getId()
) {
$context->vars_in_scope[$var_id] = Type::combineUnionTypes(
$context->vars_in_scope[$var_id],
$type
);
} elseif ($stmt_control_actions === [ScopeAnalyzer::ACTION_END]) {
$context->vars_in_scope[$var_id] = $type;
}
}

0 comments on commit 30ecde2

Please sign in to comment.
You can’t perform that action at this time.