Skip to content

Call resolver (TS/JS): ns.f() misses when the namespace import's alias differs from the file name (import * as processors from "./json-schema-processors.js") #3788

Description

@squid-protocol

What

For a qualified call ns.f(), the resolver's import shortcut matches the qualifier against the stems and directory names of the files the caller imports (imported_stems / imported_dirs in call_resolver._resolve_one). A namespace import binds an alias, and the alias is often not the file's name:

import * as processors from "./json-schema-processors.js";
processors.dateProcessor(inst, ctx, json, params);

The stem is json-schema-processors, not processors, so the shortcut misses. The call falls to the untyped-receiver ladder, which only reaches methods, and dateProcessor is a free function, so it resolves to nothing.

Evidence

callgraph_triage.py typescript (#3774) on zod: 53 reference edges in the resolved_outside bucket are processors.x() calls. These are counts from triage, not yet checked against the source.

Likely fix

This needs the alias → module mapping for namespace imports (import * as ns from "…", and const ns = require("…") in JS). Two ways to get it:

  • the import-graph edge could carry the local alias (entity_imports already exists on edge_data);
  • the detector could record namespace aliases per file.

Then ns.f() resolves through the import step to the file the alias names. The same mechanism would also serve #3758's remaining named-import case.

Activity

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

    bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing engine

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions