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 fdf1089
Browse filesBrowse the repository at this point in the historyBrowse files
fix(ast-analysis): stop misattributing complexity/CFG across same-line anonymous functions (#2265) (#2446)
Root cause was two compounding bugs, both fixed:
1. handleVarFnAssignment/handleVarFnCapture (extractors/javascript.ts)
and handle_var_decl (Rust) set a var/const-assigned function's
Definition.line from the enclosing declaration statement, not the
function value's own node. `const a = fn1, b = fn2;` gave every
declarator but the first the wrong line, so `b`'s Definition
collided with `a`'s real (correctly line-keyed) complexity/CFG
result once storeComplexityResults/storeCfgResults
(ast-analysis/apply-results.ts) indexed by each function node's own
line.
2. matchResultToDef's only disambiguation signal was `name` — always
null for an arrow function, and never the function expression's own
internal name for a var-assigned one — so it could never break a
same-line tie for this whole Definition category, fix#1 or not.
Added `column`, populated only for this category, and threaded a
column-first tier into both matchResultToDef (WASM/visitor path,
apply-results.ts) and matchNativeResult (native-standalone fallback
path, engine.ts) — a structurally separate but algorithmically
identical copy of the same matching logic, not consolidated into one
function since one operates on live tree-sitter nodes and the other
on native-computed POJOs with no such node.
Rust's own inline full-pipeline complexity/CFG attachment (handle_var_decl)
was never vulnerable to the misattribution itself — it computes and attaches
each Definition's complexity/CFG directly from its own value node, never by
a later line-keyed re-match — but still needed the line fix, since
Definition.line feeds contentHash/incremental-rebuild reconnection and
`codegraph where`, not just this matching path. column is added narrowly to
FunctionComplexityResult/FunctionCfgResult (the two NAPI-crossing structs
the native-standalone fallback path already returns), not to the widely
literal-constructed shared Definition struct in Rust, which has ~200
unrelated construction sites across every language extractor and does not
need it for this JS/TS-only bug.
docs check acknowledged: internal extractor/ast-analysis fix, no language
support, CLI, or architecture-table changes.
Impact: 12 functions changed, 0 affected
0 commit comments