What a path leaves behind: a change undone on only some ways out, a test the code has just decided #138
Loading…
Reference in a new issue
No description provided.
Delete branch "left-behind"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Based on
unread-answers(#137), and contains it: the diff shown is this piece alone.Two rules about what a function's writes leave behind on each of its paths. Each of these passed
tscstrict,safe-ts check --deny-warningsand oxlint:Two rules
unbalanced-update(warning). A change and the change that undoes it, as two statements of one statement list, and a way out between them that carries the first without the second. Pairs the code shows by itself: a boolean set and cleared;+=and-=by the same step;add/delete,set/deletewith the same key,push/pop; a place given back what aconstsaved of it; and the same made by callees (enter(mut(room))/leave(mut(room))) where a summary shows each makes that one change on every path. Ways out: areturn, athrow, anawaitwhose call can reject, aq(...)returning the error, acontinueorbreakending a loop's round. A call between the two halves is the work the pair brackets, whatever it may change. A flag left set on a writtenreturnis reported only where the function tested the flag first, as a lock: without that, "hide the old error, return on success" is reported for nothing. The fix istry/finally.decided-test(error). A place given a literal by an assignment, or by a callee that always leaves that literal there, and tested against a literal before anything could change it. The message names the line that set it. Anything that could change the place ends what is known: a write of it or of what holds it, a call given its object (a function with no body to read, a method a subclass may override, a function value, a getter,Object.assign), anawaitfor anything but the function's own locals, a join where paths disagree. The page has a table of every form of call and what it ends, each with a reported twin in the fixture.Both stand on the control-flow layer, which gained graphs reduced to what one analysis asks of them.
Evidence
delete, a restore and a callee's undo; athrow; a round ended bycontinue; a flag, a counter and a map entry around a rejecting call,fetch, aThrowingcallback,q(...)), and the 12 correct forms are silent (afinally, both outcomes handled, a function that only sets, a key kept on purpose, a failed state). Decided tests: 8 reported, 20 forms where something may have changed the place silent.q(...)and a loop's round were added.Yield and cost
Mutparameter change.What turns red on upgrade
decided-testis an error andunbalanced-updatea warning. Neither reports anything on the code measured, so nothing should.What stays unseen
lock(name)/unlock(name)on a table elsewhere).throwfrom a callee between the halves.Created with Claude Opus 5.5 (implementation) and Claude Fable 5.2 (review, acceptance tests, the summary depth) in Claude Code.
What a path leaves behind: a change undone on only some ways out, a test the code has just decided (optional: no finding on real code yet)to What a path leaves behind: a change undone on only some ways out, a test the code has just decided