A call is a call however it is spelled: by-name references, copies, Promise.reject and dropped Results are checked like the plain form #110
Loading…
Reference in a new issue
No description provided.
Delete branch "fail-closed-calls"
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?
Stacked on #109 (the soundness corpus): this PR removes one line from its list. Merge #109 first; I'll rebase this one onto
mainafterwards.The failure rules recognised a call written as
f(x)orobj.m(x)and nothing else. Write the same call another way and they said nothing, and most of the other ways are ordinary code, not evasion:In 15 of 16 test pairs, each the same program written as an arrow and by name, the two forms got different verdicts.
What changes
A call is a call however it is spelled. One normalisation step now feeds
unhandled-failure,uncaught-propagation,floating-rejectionandmust-use-result: a computed member (JSON["parse"]), aglobalThis.orwindow.prefix, a copy (aconst, destructuring, a class field, an export used from another file),.call/.apply/.bind,Reflect.applyandReflect.construct.A function used by name is the arrow that calls it.
apply(find)gets exactly whatapply((id) => find(id))gets, wherever the name is used as a value. The exception is a call that only looks the function up, compares it, removes it or prints it (removeEventListener("x", f),seen.has(f),console.log(f)): that is not a call.A rejection is a throw.
Promise.reject(x)and an executor'sreject(x)areno-throwunlessxis aPropagateError; with one, the function propagates it like athrowin anasyncfunction.A dropped
Resultis reported wherever it is dropped.must-use-resultnow follows aResultintoforEach, a timer, a listener, and a discardedlist.map(check)orawait Promise.all(list.map(save)).What an adopter will notice
New findings on code that used to pass; the CHANGELOG's Changed section says what to write for each.
no-throwonreject(new Error(...)),Promise.reject(new Error(...)), and on the executor'srejecthanded on by name (stream.on("error", reject), a pending-request map storing{ resolve, reject }). Reject with aPropagateError, or resolve with anErr.unhandled-failureon built-ins passed by name (texts.map(decodeURIComponent)).must-use-resulton aResultreturned to a timer, a listener or a droppedPromise.all.On an adopter's project the findings from its entries are identical before and after (673, compared finding by finding). Checked as whole directories, which adds tests and scripts, it gains 19
no-throw: all on rejections with a plain error, most of them in tests.How it was checked
test:std,typecheck, the docs examples,test:vite, the docs site build and the soundness corpus pass.try, lookups and removals,Results that are kept, returned, chained or voided).app.delete("/a", handler)(a route) andlogger.error(() => ...)(a lazy message). The final rule applies the name only on a known built-in, or when the function is the call's only argument.promise-reject-untracked).Still not seen
const h = { load: find }; h.load("")); a function chosen inside an argument (apply(flag ? find : String)); a default parameter (cb = find).Resultkept in a local and never looked at. That needs flow analysis and is a later PR.rejectstored in a slot whose declared type only admits aPropagateErroris stillno-throw, because the rule can't read the slot's type. One site on the adopter.Created with Claude Opus (implementation) and Claude Fable 5.2 (review and acceptance tests) in Claude Code.
Promise.rejectno longer escapesas#113