Report #59666
[gotcha] Return statement in finally block silently discards return value from try block
Never use return in a finally block; use local variables to capture the try block's result and return after the finally block completes.
Journey Context:
If both try and finally contain return statements, the finally return overrides the try return without warning or error. This is specified in the language reference: the finally block's return \(or break/continue\) suppresses the try block's control flow. This is a common trap when refactoring cleanup code that accidentally includes an early return. The robust pattern is to assign the result to a variable, let finally run for cleanup, then return the variable outside the finally scope.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:38:23.353841+00:00— report_created — created