ECMA-262 in Lean

Spec issues & errata · defect of the text · docs/spec-issues/66-module-diamond-circularity-asserts.md

66. GetExportedNames and ResolveExport assert circularity on acyclic diamond export * module graphs

Location
§16.2.1.7.2.1 GetExportedNames (#sec-getexportednames), step 3.a; §16.2.1.7.2.2 ResolveExport (#sec-resolveexport), step 3.a.i.
Kind
failing Assert (both assertions fail on any cycle-free diamond export * DAG).
Model erratum
ModuleDiamondCircularityAsserts, baked-in SpecTec reading test262 (assert pass at lines 528 and 563 of spec/spectec/clauses/S16.spectec). SpecTec silences both false circularity Assert:s so diamond export * module graphs link and evaluate without stopping.
Upstream
Checked 2026-11-19: none found (searched for "starting point of an export * circularity" and "circular import request").
On this site
ModuleDiamondCircularityAsserts on Spec issues & errata (defect of the text; SpecTec bakes in the test262 reading)

Text

GetExportedNames:

3. If exportStarSet contains module, then

a. Assert: We've reached the starting point of an export * circularity.

b. Return a new empty List.

4. Append module to exportStarSet.

ResolveExport:

3. For each Record { [[Module]], [[ExportName]] } record of resolveSet, do

a. If module and record.[[Module]] are the same Module Record and exportName is record.[[ExportName]], then

i. Assert: This is a circular import request.

ii. Return null.

4. Append the Record { [[Module]]: module, [[ExportName]]: exportName } to resolveSet.

Problem

Both algorithms pass a single mutable List (_exportStarSet_ / _resolveSet_) across all recursive export * branches and Append visited modules without popping or copying between sibling branches:

Examples

// d.mjs: export const x = 1;
// b.mjs: export * from "./d.mjs";
// c.mjs: export * from "./d.mjs";
// main.mjs:
// export * from "./b.mjs";
// export * from "./c.mjs";
// entry.mjs:
import * as ns from "./main.mjs";
print(Object.keys(ns).join(","), ns.x);
entry.mjs on diamond a -> {b, c} -> d
literal text GetExportedNames step 3.a's circularity Assert: fails (and ResolveExport step 3.a.i fails when resolving an unexported name)
V8, SpiderMonkey, JavaScriptCore "x", 1
formal model (test262 reading, assert pass) "x", 1

Proposed wording

Replace step 3.a of GetExportedNames and step 3.a.i of ResolveExport with NOTE: steps explaining that _module_ (or (_module_, _exportName_)) was already visited along the current or an earlier export * path.

test262

language/module-code/ambiguous-export-bindings/ and namespace/ test export * graphs including shared targets.