You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 95af05c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(extractor): close remaining flow-lowering gaps — finally-before-return, do, switch
Closes the last deferred control-flow recall gaps in the --flow-locals lowering, so the
flow detector now models every common construct (only goto/labeled statements and a few
exotic forms still honestly bail).
- finally-before-return: an `onReturn` continuation is threaded alongside `onThrow`
(the finally-stack + return), so a `return` inside a try-with-finally runs the finally
FIRST — a finally-disposed resource is released on the return path. Unlike `onThrow`,
`onReturn` is never suppressed by catches (a return is never caught). The old "bail the
whole method if a try-with-finally has a return" is removed; such methods are analysed,
and an early return that skips a later dispose is now caught.
- do-while: desugared `do { B } while(c)` -> `B; while(c){ B }` (the body runs 1+ times).
Modelling it as a bare 0+-trip `while` would be unsound — a resource released only in the
body but acquired outside would falsely leak on the phantom 0-trip path.
- switch: lowered to a chain of opaque, mutually-exclusive `if(*)` branches, one per
section, trailing `break` stripped (anything else — nested break, goto case, throw —
bails). With NO default the LAST case becomes the tail rather than an empty no-match
branch: that avoids a FALSE POSITIVE on an exhaustive switch (e.g. over an enum) where
every case disposes; the cost is a sound recall gap (a non-exhaustive no-match leak is
only missed when every case disposes).
All no-false-positive-preserving. Validated on the core IR via a new flow_finally_switch
fixture (silent: finally-before-return clean, switch-all-dispose; leak: early-return,
switch-else) — tests 53/53 — and end-to-end in CI on new samples (earlyRet/doLeak/swLeak
leak; other/doClean/swAll/tfRet silent). Existing samples keep their verdicts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgED
Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+14-1Lines changed: 14 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -287,6 +287,16 @@ jobs:
287
287
# ('qualLeak'); IsCatchAll matches only the canonical spellings (CodeRabbit review).
288
288
echo "$out" | grep -qE "OWN001.*'qualLeak'" \
289
289
|| { echo "FAIL: expected OWN001 on the qualified-typed-catch leak"; exit 1; }
290
+
# remaining flow-lowering gaps closed: finally-before-return threading (an early
291
+
# return that skips a later dispose leaks -> 'earlyRet'), `do` desugar (a body-local
292
+
# never disposed leaks per iteration -> 'doLeak'), and `switch` lowering (a default
293
+
# branch that does not dispose leaks -> 'swLeak').
294
+
echo "$out" | grep -qE "OWN001.*'earlyRet'" \
295
+
|| { echo "FAIL: expected OWN001 on the early-return-skips-dispose leak"; exit 1; }
296
+
echo "$out" | grep -qE "OWN001.*'doLeak'" \
297
+
|| { echo "FAIL: expected OWN001 on the undisposed local in a do-while loop"; exit 1; }
298
+
echo "$out" | grep -qE "OWN001.*'swLeak'" \
299
+
|| { echo "FAIL: expected OWN001 on the switch default-branch leak"; exit 1; }
290
300
# dispose-optional (Task), disposed/escaping locals, a `for` loop whose
291
301
# disposable is disposed after it (`looped`, balanced), a balanced
292
302
# acquire+dispose in a loop (`whileClean`), a try/finally dispose (`tfClean`,
@@ -303,7 +313,10 @@ jobs:
303
313
# `lamPrior`: a `new` inside a LAMBDA body is deferred (runs on invoke, not at the
304
314
# declaration), so the lambda statement is not a throw point -> no phantom edge skips
305
315
# its post-try dispose -> silent (Codex review: don't descend into lambda bodies).
306
-
for ok in clean looped esc exemptTask whileClean asyncDisposed asyncDisposedCfg tfClean tfCatch tfRet tfNull cda daci cif ctorLater lamPrior; do
316
+
# `other`: disposed by the finally, so threaded before the early return -> silent.
317
+
# `doClean`: acquire+dispose balanced each `do` iteration. `swAll`: every `switch`
318
+
# case disposes (no default) -> last case is the tail, no phantom no-match leak.
319
+
for ok in clean looped esc exemptTask whileClean asyncDisposed asyncDisposedCfg tfClean tfCatch tfRet tfNull cda daci cif ctorLater lamPrior other doClean swAll; do
307
320
if echo "$out" | grep -q "'$ok'"; then echo "FAIL: silent/exempt case '$ok' was reported"; exit 1; fi
308
321
done
309
322
echo "OK: flow-sensitive OWN001/002/003 on real C# (path-sensitive, loops via while/foreach/for, try/finally sequential, never-vs-every-path wording, dispose-optional exempt, beyond flat)"
0 commit comments