Skip to content

JavaScript resolver links block-scoped object-shorthand variables to unrelated functions #2606

Open

Description

@ensell-yes

Behavior

Graphify emits an indirect_call edge from a function that uses a block-scoped loop variable in an object-shorthand argument to an unrelated top-level function with the same name in another file.

Observed with graphify 0.9.39.

Minimal reproduction

declaration.mjs:

export function entry(signature) {
  return { signature };
}

export const fixture = entry("public.entry()");

consumer.mjs:

export function findNamed(entries, lookup) {
  const resolved = [];
  for (const entry of entries) {
    if (lookup(entry.name)) resolved.push({ entry });
  }

  return resolved;
}

Run:

graphify extract ./repro --code-only --force

The resulting graph includes:

findNamed() --indirect_call [INFERRED]--> entry()
source: consumer.mjs:4

Expected

No edge from findNamed() to the unrelated entry() declaration. The entry at the reported source location is a for...of lexical binding used as an object-shorthand property, not a callable identifier.

Impact

A generic fixture/helper name can become a false high-betweenness hub when this pattern appears across many files, distorting god-node and community analysis.

Suggested regression test

Build the two-file corpus above and assert there is no indirect_call edge from consumer_findnamed to declaration_entry. A positive control should retain the real fixture → entry() call.

Activity

  1. imagineers-tyler commented on Aug 17, 2026

    @imagineers-tyler
    Contributor

    Filed #2822 for the other side of this collector, since the two are easy to conflate.

    This issue is a loop binding not shadowing inside its own loop. The v0.9.42 hunk that
    addresses it folds the binding into _js_local_bound_names' function-wide set, and that set is
    also consulted for references outside the loop — so for (const k of …) …; p.submit(k) now
    loses a genuine edge to a same-named module callable. Same for an ordinary if-block const,
    which reaches the same set through the variable_declarator arm.

    Worth noting for anyone fixing either: the in-loop behaviour reported here is correct on v0.9.45
    and has to stay correct — it is a control row in #2822.

  2. omsenjalia commented on Oct 18, 2026

    @omsenjalia
    Contributor

    This looks fixed on the v8 branch by 873b5ebd (Add regression tests for block scoped let/const shadowing). Could a maintainer confirm and close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions