Skip to content

feat(resolver): resolve property calls on object destructuring rest parameters (JS) #1336

@carlos-alm

Description

@carlos-alm

Pattern

When a function parameter uses object destructuring with a rest element (`...rest`), and the rest object's property is then called, codegraph does not resolve the callee.

Failing example (from Jelly micro-test `rest.js`)

```js
var obj = {
e1: () => { console.log("31"); },
e2: () => { console.log("32"); },
e3: () => { console.log("33"); },
e4: () => { console.log("34"); }
};

function f3({ e1: eee1, ...eerest }) {
eee1();
eerest.e4(); // eerest.e4 === obj.e4 when called as f3(obj)
}
f3(obj);
```

Expected edge: `f3 → e4` (via `eerest.e4()` with `eerest` holding the rest of `obj`) — not resolved.

Relationship to #1321

Issue #1321 tracks array spread and `Array.from`/`concat`/`flat` callbacks. This issue is about object destructuring rest, where `...eerest` collects the un-destructured keys of an object parameter. The call `eerest.e4()` requires:

  1. Tracking that `eerest` is the rest of the destructured parameter `obj`
  2. Knowing the type of the argument passed to `f3` (the `obj` literal)
  3. Looking up `obj.e4` as the callee for `eerest.e4()`

Benchmark evidence

Jelly micro-test corpus (`tests/benchmarks/resolution/fixtures/jelly-micro/rest/`):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions