mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Fix control flow analysis for nested try-catch-finally statements (#39399)
* Fix control flow analysis for nested try-catch-finally statements * Add tests
This commit is contained in:
@@ -1241,6 +1241,11 @@ namespace ts {
|
||||
if (currentReturnTarget && returnLabel.antecedents) {
|
||||
addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
|
||||
}
|
||||
// If we have an outer exception target (i.e. a containing try-finally or try-catch-finally), add a
|
||||
// control flow that goes back through the finally blok and back through each possible exception source.
|
||||
if (currentExceptionTarget && exceptionLabel.antecedents) {
|
||||
addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
|
||||
}
|
||||
// If the end of the finally block is reachable, but the end of the try and catch blocks are not,
|
||||
// convert the current flow to unreachable. For example, 'try { return 1; } finally { ... }' should
|
||||
// result in an unreachable current control flow.
|
||||
|
||||
Reference in New Issue
Block a user