Skip to content

Commit

Permalink
Fix #4315 - prevent crash when setting unknown property in finally
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 15, 2020
1 parent 8f21179 commit cb3a793
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -537,7 +537,7 @@ function ($fq_catch_class) use ($codebase): Type\Atomic {
$finally_context->vars_in_scope[$var_id],
$codebase
);
} else {
} elseif (isset($finally_context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = clone $finally_context->vars_in_scope[$var_id];
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/TryCatchTest.php
Expand Up @@ -365,6 +365,13 @@ class_alias(
}
}'
],
'suppressUndefinedVarInFinally' => [
'<?php
try {} finally {
/** @psalm-suppress UndefinedGlobalVariable, MixedPropertyAssignment */
$event->end = null;
}',
],
];
}

Expand Down

0 comments on commit cb3a793

Please sign in to comment.