Feedback
Finally blocks are skipped when a Try block exits through Return
- Status
- Fixed
- Fixed in
- v26.9.4
- Area
- compiler
- Source discussion
- https://forum.objo.dev/d/1200-xecution-stops-silently-after-await-inside-select-case-finally-not-run
- Last updated
- 2026-09-28
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
A Finally block does not run when its Try block is exited by a Return statement. This affects both ordinary and Async methods.
For example, a re-entrancy guard reset in a Finally never executes after an early Return, so subsequent calls see the guard still set and appear to do nothing — the app looks frozen, with no exception raised anywhere. The same applies to resource-release patterns (Close(), Leave()) recommended for Try/Finally.
Expected behaviour: the Finally block runs on every exit path from the Try — normal completion, an exception, and an explicit Return. The language specification documents Finally as always executed.