Follow calls into methods, nested helpers, default and namespace imports, and re-exports #5
Loading…
Reference in a new issue
No description provided.
Delete branch "calls-beyond-named-functions"
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?
Closes the first item of README "Known gaps": calls were followed only into plain top-level named functions, so a
PropagateErroror a failure travelling through a method, a nested helper,ns.f(), a default import or a barrel file was dropped without a word.What changed
LocalAnalysis::functions):f,outer/inner(nested helper),C#m(instance method, also privateC##mand arrow-function properties),C.m(static),obj.m(method of a module-level object literal),default(anonymous default export). Constructors areC#constructor; instance field initializers run as part of it.Callee): a module-level name, a nested helper (resolved by binding after the walk, so calls before a hoisted declaration work), a member of a module-level binding, or a method of a known class. Calls to names bound inside functions that aren't helpers (parameters, local variables) are no longer looked up by name against top-level functions.this/superin methods,new C(), a module-levelconst x = new C()(also imported), a variable or parameter declared as exactlyC. Methods are looked up along theextendschain, across files.project.rs):import x from,import * as ns, and export tables (export { f as g } from,export { default as f } from,export *,export * as ns,export default ...) are followed to the declaring module.PropagateErrorsubclasses reached through re-exports are recognised too (before,export * from "./errors"in a barrel madethrow new NotFound()ano-throw).this.load,api.find,new Session).Still not followed (documented in README "Known gaps",
unhandled-failureanduncaught-propagation)A method call on a receiver whose class isn't visible where it's made (interface or union type,
this.repo.load(), a value returned from a call), an override in a subclass when the value is declared as the base class (dispatch goes to the class written in the code), getters and setters, functions passed around or stored, classes and objects declared inside functions, and member chains (ns.sub.f(),api.users.load()). These are left out, not guessed at. There is nodocs/overview.mdin the repo; README and the rule pages were updated instead.Tests
tests/fixtures/calls(default export, namespace import,export {..} from, renaming re-export,export *,export * as, static/instance/private/inherited/supermethods, object-literal methods withthis, a module-level instance, a parameter typed with a class, a localnew, field initializers, nested helper called before its declaration, legacy default export and method forunhandled-failure, an error class through a barrel).contextsnow expects class methods and nested helpers to propagate, and keeps a class declared inside a function as not followed. Both fixtures fail againstmain's analysis code (checked by restoringcrates/safe_ts_core/srcfrommain).cargo nextest run --workspace: 94 passed, 1 failed. The failure isfixtures_match_annotationson thefeaturesfixture (createDecipherivatmain.ts:55), which fails the same way onmain: the node pack listscreateDecipherivbut the fixture line has noexpect. Not touched here.npm run check(demo): output identical tomain.safe-ts check examples/vue/src/main.ts: no problems.npm run test:vite: passed.npm run test:docs: passed (docs examples, wasm, VitePress build).npm run test:std: 115/116;feature-node/test/manifest.test.tsfails because the local Node (v26.13.0) has APIs the manifest doesn't list. Environment-dependent, unrelated.Stacked on top of this: promise-returning functions (next PR), then
instanceofnarrowing incatch.🤖 Generated with Claude Code
The call graph only knew top-level named functions, so a PropagateError or a failure travelling through `api.load()`, `this.save()`, a nested helper, `ns.f()`, a default import or a barrel file was silently dropped: never propagated, never reported. Functions now have keys (`f`, `outer/inner`, `C#m`, `C.m`, `obj.m`, `default`), calls record what they target (a name, a nested helper, a member of a module-level binding, or a method of a known class), and the whole-program pass follows imports through export tables (`export { f as g } from`, `export *`, `export * as ns`, `export default`). A method call is followed only when the receiver's class is visible where it is made (`this`, `super`, `new C()`, a module-level instance, a variable or parameter declared as exactly `C`); anything else is still left out rather than guessed at, and the README says what. Error classes reached through re-exports now count as PropagateErrors too. Co-Authored-By: Claude Opus 5.5 <[email protected]>3553552a3dto6abacf0e11