| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ution (#2085) A this-qualified call or property read was always attributed to the nearest lexically enclosing class, even when a plain (non-arrow) function sat between the access site and that class. JS/TS does not bind `this` lexically through an ordinary function call, so `this.method()` inside an unbound callback (e.g. passed to setTimeout/addEventListener) is not guaranteed to be that class's instance — producing a false calls edge in both engines. Adds a boundary-respecting variant of findParentClass (TS) / find_parent_class (Rust) that stops the ancestor walk at an intervening plain function scope, used by the this-receiver branches of call and accessor-read extraction. Arrow functions remain transparent (they inherit this lexically), and an inline `.bind(this)` wrapper is recognized as re-establishing the outer this. When the boundary is crossed, the call is now flagged unresolved-dynamic instead of silently resolving to the wrong class. docs check acknowledged Impact: 7 functions changed, 64 affected
Greptile SummaryThe PR corrects JavaScript and TypeScript call attribution when an ordinary function interrupts lexical access to a class instance.
Confidence Score: 5/5The PR appears safe to merge; no concrete regressions or blocking issues were identified. The boundary-aware lookup is consistently implemented across the TypeScript and Rust extractors, preserves existing behavior when no boundary predicate is supplied, and handles the relevant ordinary-function, arrow-function, and inline-bound-function cases. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["this.method() / this.property"] --> B{"Walk toward nearest class"}
B --> C{"Ordinary function boundary?"}
C -->|"No"| D["Continue toward class"]
C -->|"Yes"| E{"Inline function.bind(this)?"}
E -->|"Yes"| D
E -->|"No"| F["Do not attribute access to enclosing class"]
D --> G{"Nearest class found?"}
G -->|"Yes"| H["Resolve against that class"]
G -->|"No"| F
F --> I["Call becomes unresolved-dynamic; accessor edge omitted"]
Reviews (1): Last reviewed commit: "fix(extractors): respect this-binding sc..." | Re-trigger Greptile |
Sorry, something went wrong.
Codegraph Impact Analysis7 functions changed → 64 callers affected across 8 files
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Closes #2085
A this-qualified call or property read (this.method() / this.prop) was always attributed to the nearest lexically enclosing class, even when a plain (non-arrow) function sat between the access site and that class. JS/TS does not bind this lexically through an ordinary function call, so:
previously produced a false Session.checkExplicit -> Session.isReady edge in both engines.
Changes
Verified end-to-end parity by rebuilding the native addon locally and comparing codegraph query output between --engine native and --engine wasm against the issue's repro — both now correctly report only checkArrow/checkBound as callers of Session.isReady, excluding checkExplicit.
Filed #2321 for an unrelated pre-existing artifact noticed during this investigation (.bind() called directly on an inline function expression emits a Call whose receiver is the entire function's raw source text) — out of scope for this fix.
Test plan