JS/TS: an import naming a file extension ('./x.mjs') loses the call bind of a const-arrow export #542

Closed
opened 2026-11-09 08:35:49 +01:00 by buildagent · 1 comment
Member

Summary

In JS/TS, an import whose specifier names a file extension loses the call bind of a const-arrow export. Node ESM requires the extension, and export const f = () => is the dominant modern style.

Fixture (lang-out/javascript/fixture2, verified by hand):

// shapes.mjs
export const arrow = (x) => x * 2;
export function plain(x) { return x; }
// use.mjs
import { arrow, plain } from './shapes.mjs';
arrow(3);   // name_fallback  ← import row resolves (tier1q_pass1), call does not
plain(4);   // resolves (named_import)
  • fixture4: the extensionless './shapes' resolves (tier1b_same_directory), and './shapes.js' does not.
  • fixture5: ESM importing from a CommonJS file (import {runIt} from '../a/lib.js') also stays name_fallback.

Likely cause

Verified: the candidate query in crates/indexer/src/index/import_bindings.rs:115 (prepare) admits only s.kind='function' AND s.parent_id IS NULL AND … AND s.is_named_export=1.

Inferred, not yet verified: the later step (finish) clears any prior bind of a call that has an import-binding row unless that strict candidate matched. So a const export never qualifies, and the bind another tier made is removed. This probably arrived with #510 (configured imports / named-export proof).

Proposal

  • finish may clear only binds that contradict a proven route. When no candidate qualified, the earlier bind stays.
  • Admit const/static symbols whose initializer is a function or arrow as callable named exports.

Acceptance

  • All three fixtures bind.
  • Corpus bind diff on js-express and ts-zod: additions only.
  • Mutation: restore the unconditional clear, and the fixture goes red.

Severity: high. This is a recall regression that removes correct binds, on the module style Node requires.


Filed from the per-language review on 2026-11-09: 8 agents, one per language plus one for Vue/Svelte/XAML/timeline, run against copies of the pinned corpus repos (tests/corpus/corpus.toml) using installed build 2dcfc615, which differs from master only by XAML/CI commits. The top claim of every issue was spot-checked in the main session. Artifacts live under the review session's scratchpad lang-out/<lang>/ and are available on request.

## Summary In JS/TS, an import whose specifier **names a file extension** loses the call bind of a `const`-arrow export. Node ESM *requires* the extension, and `export const f = () =>` is the dominant modern style. Fixture (`lang-out/javascript/fixture2`, verified by hand): ```js // shapes.mjs export const arrow = (x) => x * 2; export function plain(x) { return x; } // use.mjs import { arrow, plain } from './shapes.mjs'; arrow(3); // name_fallback ← import row resolves (tier1q_pass1), call does not plain(4); // resolves (named_import) ``` - `fixture4`: the extensionless `'./shapes'` resolves (`tier1b_same_directory`), and `'./shapes.js'` does not. - `fixture5`: ESM importing from a CommonJS file (`import {runIt} from '../a/lib.js'`) also stays name_fallback. ## Likely cause **Verified:** the candidate query in `crates/indexer/src/index/import_bindings.rs:115` (`prepare`) admits only `s.kind='function' AND s.parent_id IS NULL AND … AND s.is_named_export=1`. **Inferred, not yet verified:** the later step (`finish`) clears **any** prior bind of a call that has an import-binding row unless that strict candidate matched. So a `const` export never qualifies, and the bind another tier made is removed. This probably arrived with #510 (configured imports / named-export proof). ## Proposal - `finish` may clear only binds that **contradict** a proven route. When no candidate qualified, the earlier bind stays. - Admit `const`/`static` symbols whose initializer is a function or arrow as callable named exports. ## Acceptance - All three fixtures bind. - Corpus bind diff on js-express and ts-zod: additions only. - Mutation: restore the unconditional clear, and the fixture goes red. Severity: high. This is a recall regression that removes correct binds, on the module style Node requires. --- _Filed from the per-language review on 2026-11-09: 8 agents, one per language plus one for Vue/Svelte/XAML/timeline, run against copies of the pinned corpus repos (`tests/corpus/corpus.toml`) using installed build `2dcfc615`, which differs from master only by XAML/CI commits. The top claim of every issue was spot-checked in the main session. Artifacts live under the review session's scratchpad `lang-out/<lang>/` and are available on request._
Author
Member

Consolidated into #543 during the 2026-11-09 triage. The remaining scope of this issue is tracked there as a checklist item; this report stays as the detailed evidence.

Consolidated into **#543** during the 2026-11-09 triage. The remaining scope of this issue is tracked there as a checklist item; this report stays as the detailed evidence.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#542
No description provided.