Skip to content

Conversation

@hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Nov 19, 2023

Fix the handling of try? and throwing expressions in ternaries and if statement conditions.

rdar://118883320

@hamishknight hamishknight force-pushed the try-try-again branch 2 times, most recently from a764095 to 53ebeef Compare November 20, 2023 19:05
Previously the branches of a ternary would cut off
the coverage after a throwing expression, since
they have their own region, and we pop child
regions when leaving. Update the logic to use the
existing counter adjustment logic when we leave
the scope, ensuring that we push a new counter to
reflect the exit count of the scope.
Ensure that `try?` expressions appropriately
scope the regions generated by child
error-throwing expressions, such that the
non-error branch does not extend beyond the region
of the `try?`.
Previously we would ignore the effect that an if
statement or ternary's condition exit counter might
have on its branches, as we assumed a condition
can't do any control flow. However, in the case
where the condition throws an error, we need to
account for the error branch.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit b430a02 into swiftlang:main Nov 27, 2023
@hamishknight hamishknight deleted the try-try-again branch November 27, 2023 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants