Skip to content

fix(js): extract destructured, array, and rest parameters in _extract_parameters - #1591

Merged
Shashankss1205 merged 2 commits into
CodeGraphContext:mainfrom
AloysJehwin:fix/js-destructured-params
Aug 8, 2026
Merged

Shashankss1205 merged 2 commits into
CodeGraphContext:mainfrom
AloysJehwin:fix/js-destructured-params

Conversation

@AloysJehwin

Copy link
Copy Markdown
Contributor

Fixes part of #1527 (JavaScript bug #4).

_extract_parameters was only handling identifier, assignment_pattern, and rest_pattern. Three cases were silently dropped:

  • object_pattern — function f({x, y}) → args: [] (React's dominant prop pattern)
  • array_pattern — function f([a, b]) → args: []
  • rest_pattern — function f(...args) → args: [] because the code was looking for a named field that doesn't exist; the identifier is a direct child

Fixed all three. For destructured patterns, a placeholder ({...} / [...]) is recorded so the parameter slot is not silently lost. Rest params now walk direct children when no named field exists.

6/6 tests pass including the new regression test.

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@AloysJehwin is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

Emitting '{...}' / '[...]' preserved arity but created Parameter nodes
whose names mean nothing. The binding is the name later code refers to —
`function Button({label})` is the dominant React idiom and `label` is
what appears in the body — so record it:

    function Button({label, onClick})  -> ['{label, onClick}']
    function renamed({c: cc, d = 1})   -> ['{cc, d}']      (local, not key)
    function nested({a: {b}})          -> ['{b}']
    function mixed(a, {b}, [c], ...r)  -> ['a','{b}','[c]','...r']

Still one entry per parameter position, so arity — which call resolution
matches on — is unchanged.

Golden for sample_project_javascript: +3 Parameter nodes, nothing lost.

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: trial-merged with the other four — full suite green (1153 passed, 7 skipped).

The three cases you identified are exactly right, and the rest_element/rest_pattern fallback chain is a good catch — the old code read an argument field that node type doesn't have.

One change I pushed to your branch. The destructured cases emitted literal "{...}" / "[...]". That preserves arity, but creates Parameter nodes whose names carry no information — and the binding name is the thing later code actually refers to. function Button({label}) is the dominant React idiom precisely because label is what appears in the body.

Now records the names, still one entry per parameter position so arity is unchanged:

function Button({label, onClick})  -> ['{label, onClick}']
function renamed({c: cc, d = 1})   -> ['{cc, d}']      # local name, not the key
function nested({a: {b}})          -> ['{b}']
function mixed(a, {b}, [c], ...r)  -> ['a','{b}','[c]','...r']

{c: cc} binding cc rather than c is the case most likely to be got wrong, so it has its own assertion.

Golden for sample_project_javascript: +3 Parameter nodes, nothing lost — verified by counting node labels before and after rather than reading the line diff.

This closes the JavaScript item of #1527. Thanks!

@Shashankss1205
Shashankss1205 merged commit 5c10ea7 into CodeGraphContext:main Aug 8, 2026
16 of 17 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog tasks to Done in CGC Progress Board Aug 8, 2026
Shashankss1205 added a commit that referenced this pull request Aug 8, 2026
Ten PRs since 0.5.6 — mostly parser correctness, all with regression tests.

Parsers
- Ruby nested classes no longer delete their parent; method parameters
  extracted at all (#1523, #1527, #1581)
- C/C++ functions returning a pointer or reference are extracted, and
  registered in pre_scan so they resolve as call targets (#1524, #1582)
- C# fields and locals parsed, restoring receiver-type inference for
  `var x = new T(); x.M();` (#1525, #1584)
- JavaScript destructured, array and rest parameters extracted, recording
  the binding names rather than a placeholder (#1527, #1591)

Queries and analysis
- Five defects that returned wrong answers without erroring: inflated
  repository stats, misattributed callers, discarded graph_name,
  count(*) after OPTIONAL MATCH, an ignored tool argument (#1577)
- Dead-code detection made correct and self-consistent, including the
  JS module-level false positive (#600, #1559, #1578)

Indexing
- add_package_to_graph on a flat module no longer indexes the whole
  virtualenv (#1528, #1586)
- SCIP job progress no longer exceeds 100% (#1535, #1583)

Docs and tests
- Database Options table columns realigned (#1590)
- MCP tool definition contract validation (#1580)

Co-authored-by: Claude Fable 5 <[email protected]>
@Shashankss1205 Shashankss1205 added gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:exceptional GSSoC quality: x1.5 contributor / +10 mentor type:bug GSSoC type bonus: bug labels Aug 15, 2026
Shashankss1205 added a commit that referenced this pull request Aug 18, 2026
…issues; finish the #1527 parameter audit (#1648)

* perf(kuzu): batch relationship-only UNWIND MERGEs; scope the per-row fallback to node-MERGE shapes (#1605)

Kuzu 0.11.3's MERGE pipeline mis-binds when a merged NODE's key repeats
non-adjacently in one UNWIND batch ([(A,P),(B,X),(C,P)] binds C to X) —
reproduced minimally and pinned in tests. Relationship-only MERGEs
(MATCH..MATCH..MERGE rel) do not exhibit the bug, verified with interleaved
duplicate endpoint keys and duplicate pairs, so they now run batched: the
full integration suite drops from ~5:06 to ~4:09 (-20%) and a sample-project
index halves. Inheritance batches are also deduped writer-side so a repeated
(child, parent) record cannot double an INHERITS edge on embedded backends.

* fix(indexer): retry a failed per-file graph write once before recording it (#1612)

A transient write failure under runner load silently cost the graph a whole
file's edges (LadybugDB intermittently 51 CONTAINS short in the parity run).
Writes are MERGE-idempotent, so one retry converts the blip into success;
persistent failures still land in write_failures and the error log. Together
with the #1605 batching change (which removes most of the per-row write
pressure the flake correlated with), this addresses the observed drop.

* test(cgcignore): make the CLI cases hermetic and move them to the integration suite (#1422)

The TC-12+ cases shared one fixed /tmp/cgc_test/_home database across every
test and run, wiped it mid-suite, and were gated on a live Neo4j — so they
were permanently skipped on most machines and intermittently failed with a
different name each full-suite run wherever they did run. Each test now gets
a fresh HOME and an explicit embedded backend (no server, no gate, no wipe),
and the subprocess-driven cases live in tests/integration where that cost
belongs. tc01-tc11 (pure PathSpec logic) stay in the unit suite.

* fix(cpp): extract lambda parameters through the shared param helper (#1527)

The inline version first clobbered its correctly-walked parameter_list with
a nonexistent 'parameters' field on lambda_expression, then filtered for
bare identifiers over parameter_declaration nodes — every lambda assignment
got args: []. lambda_expression carries the same declarator→parameters field
chain as function_definition, so the shared extractor handles it, rendering
args in the project's established 'type name' form. Last remaining case of
the #1527 parameter audit (Ruby #1581, PHP key + #1643, JS #1591 all landed
previously).

* regen cpp golden: lambda Parameter nodes now extracted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:exceptional GSSoC quality: x1.5 contributor / +10 mentor type:bug GSSoC type bonus: bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants