fix(extraction): index const-bound functions inside a body as symbols - #1679
Open
danusha2345 wants to merge 1 commit into
Open
fix(extraction): index const-bound functions inside a body as symbols#1679danusha2345 wants to merge 1 commit into
danusha2345 wants to merge 1 commit into
Conversation
…colbymchenry#1669) `const handleClear = () => {…}` inside a component — every React handler that skips useCallback — was never a symbol: the body walker only named nested function declarations and hook-bound arrows, so the handler was absent from callers/impact ("Symbol not found", indistinguishable from "no callers") and its calls attributed to the component. Bind the arrow or function expression to its declarator the way module scope already does, in both the wasm walker and the kernel. A navigation such a handler makes is now the handler's own edge and a hop in the Screens `via` chain — the shape a useCallback handler already has — so the react-router and expo-router expectations follow that convention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1669.
Problem
const handleClear = () => {…}inside a component — every React handler written withoutuseCallback— was never a symbol. The body walker names nested function declarations and hook-bound arrows (const x = useCallback(…)), but a plain declarator-bound arrow or function expression fell through, so the handler was absent fromcallers/callees/ impact ("Symbol not found", which reads exactly like "no callers") and its calls attributed to the component. The same declaration at module scope already names a function.Change
arrow_function/function_expressionthat is the wholevalueof avariable_declaratorwith a plain identifier name is extracted as a function, contained by the enclosing one, with its own calls.extractFunctionalready resolves the name from the declarator. A destructuring binding, an inline JSX arrow and a non-function value stay as they were. JS family only.torture.tsxgains the shape sokernel-tsjs-paritypins both arms.Graph shape
A navigation such a handler makes is now the handler's own
navigatesedge, and the handler is a hop in the Screensviachain — the shape auseCallbackhandler already has (see the Next.js test'snavs(sym('handleSubmit'))andpush.via). The react-router and expo-router expectations are updated to that convention; the screen still reaches the handler through itsonSubmit={…}reference and the links resolve as before, with the trigger now visible in Steps.Verification
__tests__/nested-declarator-functions.test.ts: arrow, function expression andlet-bound arrow becomeWidget::namefunctions with their own calls and containment; a value, a destructuring and an inline arrow do not; Python is untouched.npm run build:kernel && npm run build, full suite withCODEGRAPH_KERNEL_EXPECT=1: 237 files, 4233 passed, 9 skipped.Re-index after upgrading to pick up the new symbols.
🤖 Generated with Claude Code