Repository navigation
fix: forward the sourcename through the pre-init parse path - #236
Merged
Merged
Conversation
`parse(source, name)` called before `init` resolves recursed as
`parse(source)`, so `name` fell back to its `'@'` default and a
caller-supplied sourcename was dropped from the parse error message.
Calling parse asynchronously is a documented path, and so is the second
argument, so the two are usable together but did not compose:
parse('import{', 'my-file.js') // awaited init: Parse error my-file.js:1:11
// pre-init: Parse error @:1:11
Only the wasm builds have this branch. The test picks up a second,
uninitialized module instance so it can reach it from inside the suite,
which has already awaited init.
hdimer
marked this pull request as ready for review
August 16, 2026 03:52
mergify Bot
added a commit
to ArcadeData/arcadedb
that referenced
this pull request
Aug 23, 2026
…2.3.2 in /studio [skip ci] Bumps [es-module-lexer](https://github.com/guybedford/es-module-lexer) from 2.3.1 to 2.3.2. Release notes *Sourced from [es-module-lexer's releases](https://github.com/guybedford/es-module-lexer/releases).* > 2.3.2 > ----- > > What's Changed > -------------- > > * perf(lexer): skip identifier and number runs by [`@BridgeAR`](https://github.com/BridgeAR) in [guybedford/es-module-lexer#227](https://redirect.github.com/guybedford/es-module-lexer/pull/227) > * fix: annotate asm.js integer return type by [`@Justineo`](https://github.com/Justineo) in [guybedford/es-module-lexer#230](https://redirect.github.com/guybedford/es-module-lexer/pull/230) > * Add side effects to package.json by [`@denisx`](https://github.com/denisx) in [guybedford/es-module-lexer#183](https://redirect.github.com/guybedford/es-module-lexer/pull/183) > * fix: forward the sourcename through the pre-init parse path by [`@hdimer`](https://github.com/hdimer) in [guybedford/es-module-lexer#236](https://redirect.github.com/guybedford/es-module-lexer/pull/236) > > New Contributors > ---------------- > > * [`@Justineo`](https://github.com/Justineo) made their first contribution in [guybedford/es-module-lexer#230](https://redirect.github.com/guybedford/es-module-lexer/pull/230) > * [`@denisx`](https://github.com/denisx) made their first contribution in [guybedford/es-module-lexer#183](https://redirect.github.com/guybedford/es-module-lexer/pull/183) > * [`@hdimer`](https://github.com/hdimer) made their first contribution in [guybedford/es-module-lexer#236](https://redirect.github.com/guybedford/es-module-lexer/pull/236) > > **Full Changelog**: <guybedford/es-module-lexer@2.3.1...2.3.2> Commits * [`08ee1be`](guybedford/es-module-lexer@08ee1be) fix: forward the sourcename through the pre-init parse path ([#236](https://redirect.github.com/guybedford/es-module-lexer/issues/236)) * [`5a824a1`](guybedford/es-module-lexer@5a824a1) Update package.json ([#183](https://redirect.github.com/guybedford/es-module-lexer/issues/183)) * [`8274d03`](guybedford/es-module-lexer@8274d03) fix: annotate asm.js integer return type ([#230](https://redirect.github.com/guybedford/es-module-lexer/issues/230)) * [`2abc49e`](guybedford/es-module-lexer@2abc49e) perf(lexer): skip identifier and number runs ([#227](https://redirect.github.com/guybedford/es-module-lexer/issues/227)) * See full diff in [compare view](guybedford/es-module-lexer@2.3.1...2.3.2) [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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.
When
parse()is called beforeinitresolves, it recurses asparse(source)and dropsname, which then falls back to its'@'default. The README documents the second argument (parse(source, 'optional-sourcename')) and it documents calling parse before init ("either await init, or call parse asynchronously"), but the two don't compose:So anyone lexing a batch of files on the async path gets every error labelled
@.The fix is to pass
namethrough the recursion. Only the wasm builds have this branch —src/lexer.asm.jsand the plain JS build parse synchronously from the first call.The test goes in the
Invalid syntaxsuite behind theWASMgate. It imports a second module instance via a query string, since the suite's own instance has already awaitedinitand can't reach the branch. Verified it fails withParse error @:1:11without the fix.test:wasmandtest:minimal:wasmpass (150 each).I left the
as unknown ascast on that line alone deliberately — that's #155 and it needs a breaking type change, which didn't belong in the same diff.Disclosure: I used an AI assistant while working on this. I reproduced the bug, reviewed the change, and ran the test suite myself.