Commit ef54c12
authored
fix(resolver): scope Phase 8.3f typeMap key by callee to avoid same-name rest-param collision (#1368)
* feat(resolver): resolve property calls on object destructuring rest parameters (JS)
When a function parameter uses object destructuring with a rest element
(`...rest`) and the rest object's property is then called, codegraph now
resolves the callee.
Resolution chain (Phase 8.3f):
1. JS extractor seeds typeMap['obj.X'] = { type: 'X' } for shorthand
properties in object literals (`var obj = { e4 }`).
2. New extractObjectRestParamBindingsWalk records objectRestParamBinding
{ callee, argIndex, restName } from `function f({ a, ...rest })`.
3. build-edges.ts cross-references with paramBindings from f(obj) calls
to seed typeMap[restName] = { type: argName, confidence: 0.65 }.
4. resolveByMethodOrGlobal: typeMap[restName] → obj; typeMap[obj.method]
→ method → resolved edge.
Adds:
- ObjectRestParamBinding type + ExtractorOutput.objectRestParamBindings field
- objectRestParamBindings serialised through WASM worker boundary
- extractObjectRestParamBindingsWalk in javascript.ts
- Object literal shorthand property seeding in handleVarDeclaratorTypeMap
- Phase 8.3f typeMap seeding in buildCallEdgesJS
- 6 unit tests in tests/parsers/javascript.test.ts
- Integration test (WASM engine) in issue-1336-object-rest-param-resolution.test.ts
- Jelly micro-test fixture tests/benchmarks/resolution/fixtures/jelly-micro/rest/
Files issue #1348 (missing WASM worker serialisation for paramBindings/
returnTypeMap/callAssignments) and #1349 (native engine parity) as follow-ups.
Closes #1336
* fix(native): add object destructuring rest-parameter resolution (Phase 8.3f parity)
Add buildObjectRestParamPostPass to the native call-edge path, mirroring the
Phase 8.3f seeding already present in buildCallEdgesJS (WASM path).
The post-pass seeds typeMap[restName] = { type: argName } by cross-referencing
objectRestParamBindings (which formal param uses a rest binding) with
paramBindings (which call-site arg was passed). It then resolves calls whose
receiver is the rest-binding name via resolveCallTargets with the enriched
typeMap, adding any edges the native Rust engine missed.
For same-file and directly-imported callees, the native Rust engine already
resolves via its own same-file (step 2) and import-aware (step 1) lookups;
seenByPair prevents duplicate edges. The post-pass provides the typeMap-chain
fallback for the cross-file non-imported case where the chain
typeMap[restName] → argName → typeMap[argName.method] → target resolves
a callee the Rust engine cannot find.
Also updates the #1336 integration test to assert both WASM and native engines
produce the f3 → e4 edge.
Closes #1349
* feat(extractor): extend rest-param binding walk to class and object-literal methods (#1357)
docs check acknowledged
* fix(resolver): defensive-copy typeMap in buildCallEdgesJS Phase 8.3f block
Native buildObjectRestParamPostPass already clones symbols.typeMap before seeding
(line 755); the WASM path buildCallEdgesJS was taking a direct reference, causing
Phase 8.3f seeds to persist into symbols.typeMap across watch/incremental builds
and blocking correct re-seeding when call-site arguments changed.
Tracks rest-param scoping gap (two functions with same restName in one file) in
issue #1358.
* test(1336): add dynamic:0 assertion to native engine integration test
Native test for the rest-receiver edge (f3 → e4) was only checking that the
edge exists; it now also asserts dynamic===0, matching the WASM test. This
ensures a dynamic-dispatch fallback in the native engine is caught as a
regression.
* fix(resolver): scope Phase 8.3f typeMap key by callee — avoid rest-param name collision (#1358)
Two functions in the same file both using `...rest` as their rest-binding name
caused the first seeding to win via the `!typeMap.has(restName)` guard, so the
second function resolved via the wrong argument type.
Fix: key the typeMap entry as `callee::restName` (e.g. `f2::rest`) in both the
WASM seeding (buildCallEdgesJS) and the native post-pass (buildObjectRestParamPostPass).
resolveByMethodOrGlobal gains a third fallback that tries the scoped key via
callerName when the unscoped lookup misses. The native post-pass now passes
caller.callerName to resolveCallTargets so the scoped lookup has the context it needs.
Also moves restNames.add() outside the guard in the native post-pass so that all
rest-binding names — not just the first per name — are registered for the receiver
filter, enabling calls from both f1 and f2 to pass through to resolution.
Closes #1358
* fix(resolver): unscoped fallback for null-callerName; negative cross-edge assertions (#1358)
When only one callee uses a given rest name, also seed the unscoped key alongside
the scoped `callee::restName` key. This preserves resolution when callerName is null
(e.g. enclosing function node not in DB during incremental rebuild) — no collision
risk since there is only one callee using that rest name.
When two or more callees share a rest name, only scoped keys are seeded (the
ambiguous collision case — unscoped would point to the wrong type).
Also adds negative assertions to the #1358 test: verifies f1→m2 and f2→m1 are
absent, guarding against false cross-edges from the pre-fix collision.
Tracks incremental-path callerName gap in #1369.
Impact: 2 functions changed, 3 affected
* docs(test): correct resolution-path comment in issue-1336 test (#1368)
Step 5 previously described resolution via the scoped key 'f3::eerest', but
since f3 is the only callee using 'eerest', the single-callee shortcut also
seeds the unscoped key 'eerest', which resolveByMethodOrGlobal hits first.
The scoped key is a no-op in the single-callee case but is the active path
when two functions share the same rest-param name.
* fix: remove extra blank line in javascript.ts (biome format) (#1368)
* fix(wasm-worker): remove duplicate objectRestParamBindings spread (#1368)1 parent 732def4 commit ef54c12
6 files changed
Lines changed: 167 additions & 24 deletions
File tree
- src/domain/graph/builder
- stages
- tests
- benchmarks/resolution/fixtures/jelly-micro/rest
- integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
759 | | - | |
760 | | - | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
761 | 771 | | |
762 | 772 | | |
763 | 773 | | |
764 | 774 | | |
765 | | - | |
766 | | - | |
767 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
768 | 781 | | |
| 782 | + | |
769 | 783 | | |
770 | 784 | | |
771 | 785 | | |
| |||
777 | 791 | | |
778 | 792 | | |
779 | 793 | | |
780 | | - | |
| 794 | + | |
| 795 | + | |
781 | 796 | | |
782 | 797 | | |
783 | 798 | | |
784 | 799 | | |
785 | 800 | | |
786 | 801 | | |
787 | 802 | | |
| 803 | + | |
788 | 804 | | |
789 | 805 | | |
790 | 806 | | |
| |||
1019 | 1035 | | |
1020 | 1036 | | |
1021 | 1037 | | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
1026 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1027 | 1049 | | |
1028 | 1050 | | |
1029 | 1051 | | |
1030 | | - | |
1031 | | - | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
1032 | 1058 | | |
1033 | 1059 | | |
1034 | 1060 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
7 | 17 | | |
8 | | - | |
| 18 | + | |
9 | 19 | | |
| 20 | + | |
| 21 | + | |
10 | 22 | | |
11 | | - | |
12 | | - | |
| 23 | + | |
| 24 | + | |
13 | 25 | | |
14 | 26 | | |
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
0 commit comments