Support re-exporting source-phase imports#2490
Merged
Merged
Conversation
Implements the spec plumbing for `import source x from "..."; export { x };`
so the three previously-excluded module tests pass:
- language/module-code/source-phase-import/reexport-source-binding-named-import.js
- language/module-code/source-phase-import/reexport-source-binding-namespace-get.js
- language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-import-source-and-export.js
A module record now carries an internal [[ModuleSource]] slot (Module.cs).
ModuleLoader exposes a `protected virtual GetModuleSource` hook (default null,
so an ordinary JS module still rejects a source-phase import); LoadModule
attaches its result. SourceTextModule.InitializeEnvironment binds a direct
`import source x` to the imported module's [[ModuleSource]] (TypeError when
absent, preserving import-source.js). Re-export is reclassified in
HoistingScope as an indirect export with a "*source*" import name; ResolveExport
returns a "*source*" binding, InitializeEnvironment binds it to [[ModuleSource]]
(SyntaxError when absent), and ModuleNamespace.[[Get]] returns [[ModuleSource]]
(ReferenceError when absent).
The test harness (Test262ModuleLoader) resolves the test262 `<module source>`
specifier to a trivial module and overrides GetModuleSource to return an object
whose prototype is $262.AbstractModuleSource.prototype, matching INTERPRETING.md's
guidance that the host supplies a module source (Jint has no WebAssembly).
The slice/speciesctor-return-same-buffer-with-offset.js exclusion remains: it is
an upstream test262 bug (commit 21513be91f) that runs the immutable-buffer factory
while expecting a write to succeed, which a spec-correct slice rejects. The
exclusion comment documents this for an upstream report.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lahma
force-pushed
the
source-phase-import-reexport
branch
from
June 1, 2026 19:05
5e5756a to
93c1704
Compare
lahma
enabled auto-merge (squash)
June 1, 2026 19:07
This was referenced Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2489. Implements the module-system plumbing for re-exporting a source-phase import (
import source x from "..."; export { x };) so the three test files that #2489 had to exclude now pass, leaving only one (upstream-buggy) exclusion from that update.What this enables
Per test262's
INTERPRETING.md, the host is expected to resolve the<module source>specifier to a module exposing a[[ModuleSource]](WebAssembly being the canonical example). Jint has no WebAssembly support, so the test harness supplies a synthetic module source — the sanctioned approach — and the engine gains the general source-phase re-export semantics.Engine changes (all
internal, one newprotected virtualhook)Modulegains an internal[[ModuleSource]]slot (null for ordinary modules).ModuleLoaderexposesprotected virtual ObjectInstance? GetModuleSource(engine, resolved)(defaultnull);LoadModuleattaches its result. With the default, a source-phase import of an ordinary JS module still rejects (soimport-source.jskeeps passing).SourceTextModule.InitializeEnvironmentbinds a directimport source xto the imported module's[[ModuleSource]](TypeError if absent — the host-defined non-SyntaxError rejectionimport-source.jsasserts).HoistingScopereclassifiesexport { x }of a source-phase import as an indirect export with a"*source*"import name;ResolveExportreturns a"*source*"binding;InitializeEnvironmentbinds it to[[ModuleSource]](SyntaxError if absent);ModuleNamespace.[[Get]]returns[[ModuleSource]](ReferenceError if absent).Test harness
Test262ModuleLoaderresolves<module source>to a trivial module and overridesGetModuleSourceto return an object whose prototype is$262.AbstractModuleSource.prototype, satisfyingx instanceof $262.AbstractModuleSource. The three exclusions are removed fromTest262Harness.settings.json.Verification
Full test262 suite: 0 failures, 99208 passed (+3 vs #2489), no module/defer/namespace regressions;
import-source.jsstill passes.Jint.Testsmodule suite andJint.Tests.PublicInterfaceare green.Not addressed here
built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.jsstays excluded — it is an upstream test262 bug (commit21513be91f): it runs the immutable-buffer arg factory while expecting a write into an immutable buffer to succeed, contradicting%TypedArray%.prototype.slicestep 13/14 of proposal-immutable-arraybuffer (the species destination is created with~write~and must be non-immutable). The exclusion comment documents this; it will be reported upstream.🤖 Generated with Claude Code