Commit 09d3365
committed
flow: keep
The explicit-throw exit keyed on `onThrow is null && canEscape`, but `finally`
bodies are lowered with the default (null) onThrow — so a `throw` INSIDE a finally
also took the bare-return branch, terminating before any ENCLOSING finally runs.
For `try { try {} finally { throw; } } finally { s.Dispose(); }` that bare exit
skips the outer `s.Dispose()` and falsely reports OWN001 on `s`.
Guard the body-level throw branch with `!IsInsideFinally(thr)`: a throw lexically
inside a finally keeps bailing the whole method (the sound honest-skip it had
before this feature), since its real continuation is the OUTER cleanup the bare
exit cannot run. Body-level throws (no enclosing try/finally) are unaffected.
Sample ThrowInFinallyBails pins the Codex repro as silent; the four body-level
throw samples keep their verdicts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgEDthrow inside a finally bailing — fix false leak past an outer finally (Codex P2)1 parent 7f598b0 commit 09d3365
3 files changed
Lines changed: 41 additions & 2 deletions
File tree
- .github/workflows
- frontend/roslyn
- OwnSharp.Extractor
- samples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
715 | | - | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
716 | 719 | | |
717 | 720 | | |
718 | 721 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
567 | 585 | | |
568 | 586 | | |
569 | 587 | | |
| |||
962 | 980 | | |
963 | 981 | | |
964 | 982 | | |
965 | | - | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
966 | 986 | | |
967 | 987 | | |
968 | 988 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
324 | 340 | | |
325 | 341 | | |
326 | 342 | | |
| |||
0 commit comments