Skip to content

Name the re-exported module when a re-export is missing#1586

Merged
saghul merged 2 commits into
quickjs-ng:masterfrom
littledivy:fix/reexport-error-module
Jul 18, 2026
Merged

Name the re-exported module when a re-export is missing#1586
saghul merged 2 commits into
quickjs-ng:masterfrom
littledivy:fix/reexport-error-module

Conversation

@littledivy

@littledivy littledivy commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

export { x } from "./mod.js" where ./mod.js does not export x reported:

SyntaxError: Could not find export 'x' in module '<re-exporter>'

It named the module containing the re-export statement instead of ./mod.js, the module that was supposed to provide x. A direct import { x } from "./mod.js" already named ./mod.js correctly.

statement in a.js, targeting helper.js module named before module named after
import { missing } from "./helper.js" helper.js helper.js
export { missing } from "./helper.js" a.js helper.js

The indirect export check now reports the resolved target module and the name looked up there, same as the direct import path.

Disclaimer: This is an AI-assisted patch from the v8x project.

@littledivy
littledivy force-pushed the fix/reexport-error-module branch 2 times, most recently from 0a50dd6 to a6a2260 Compare July 17, 2026 20:02
`export { x } from "./mod.js"` where "./mod.js" has no export `x` reported
"Could not find export 'x' in module '<re-exporter>'", naming the module
that contains the re-export statement rather than the module that was
supposed to provide the binding. A direct `import { x } from "./mod.js"`
already reported "./mod.js" correctly.

Report the resolved target module and the looked-up name, matching the
direct-import diagnostic.
@littledivy
littledivy force-pushed the fix/reexport-error-module branch from a6a2260 to 68aea43 Compare July 17, 2026 20:22
The module path in the SyntaxError is written into a fixed-size atom
buffer (ATOM_GET_STR_BUF_SIZE = 64), so on CI's long absolute build
paths the fixture filename is truncated before the distinguishing
suffix. The substring assertion on "fixture_reexport_source" therefore
failed even though the fix was correct.

Assert instead that the re-export error message equals the message from
a direct import of the same missing binding. Both name the source module
and the same looked-up name, so the messages are identical regardless of
path length, which is exactly the behavior the fix guarantees.
@saghul
saghul merged commit 08fe862 into quickjs-ng:master Jul 18, 2026
128 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants