Skip to content

Commit

Permalink
Update vars_possibly_in_scope in TryAnalyzer.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrolGenhald committed Feb 20, 2022
1 parent 9a3b46b commit 6e33152
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
Expand Up @@ -561,6 +561,7 @@ private static function applyCatchContextsForFinallyContext(
$context->vars_in_scope[$var_id] = Type::combineUnionTypeArray($types, $codebase);
$context->vars_in_scope[$var_id]->possibly_undefined = $possibly_undefined;
$context->vars_in_scope[$var_id]->possibly_undefined_from_try = false;
$context->vars_possibly_in_scope[$var_id] = true;
}
}

Expand Down Expand Up @@ -630,6 +631,7 @@ private static function applyCatchContextsForOuterContext(
$context->vars_in_scope[$var_id] = Type::combineUnionTypeArray($types, $codebase);
$context->vars_in_scope[$var_id]->possibly_undefined = $possibly_undefined;
$context->vars_in_scope[$var_id]->possibly_undefined_from_try = false;
$context->vars_possibly_in_scope[$var_id] = true;
}

if (count($leaving_catches) < $catch_block_count) {
Expand All @@ -645,6 +647,7 @@ private static function applyCatchContextsForOuterContext(
// Set all variables to their types at the end of the `try` block, since
// it would have to complete successfully for execution to continue.
$context->vars_in_scope = $end_of_try_context->vars_in_scope;
$context->vars_possibly_in_scope = $end_of_try_context->vars_possibly_in_scope;
$context->references_in_scope = $end_of_try_context->references_in_scope;
}
}
Expand Down

0 comments on commit 6e33152

Please sign in to comment.