Visitar URL original
fix: annotate asm.js integer return type by Justineo · Pull Request #230 · guybedford/es-module-lexer · GitHub
Skip to content

fix: annotate asm.js integer return type - #230

Merged
guybedford merged 1 commit into
guybedford:mainfrom
Justineo:fix/asm-return-type
Aug 9, 2026
Merged

guybedford merged 1 commit into
guybedford:mainfrom
Justineo:fix/asm-return-type

Conversation

@Justineo

@Justineo Justineo commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor
AI disclosure — Codex, GPT-5.6 Sol (Extra High)

This PR was researched, implemented, tested, and drafted by Codex. I provided the requirements, requested alignment with project conventions, and approved publication.

Codex was asked to:

Codex reviewed the build history, asm.js rules, and V8 behavior; changed return b to return b | 0; and added an explicit asm.js validation test.

Validation covered published versions 2.0.0–2.3.1, Node 16–25, full and minimal bundles, and behavior comparison across 20 source files. The complete chomp test matrix is pending CI approval.

Summary

Since 2.2.0, invoking the es-module-lexer/js build under V8 emits:

Invalid asm.js: Invalid return type

The bundle remains valid JavaScript, so V8 falls back to normal JavaScript compilation and parsing still succeeds. This allows the existing functional tests to pass while the asm.js module itself fails validation.

The regression was introduced by #203. Its injected allocator helper returns an integer parameter without the result coercion required by asm.js:

function su(a, b) {
  a = a | 0;
  b = b | 0;
  v = a + b + 15 & -16;
  return b;
}

Returning b is the intended behavior; only its asm.js return type annotation is missing.

Changes

  • Change the allocator return to return b | 0
  • Add a V8-specific regression test for both full and minimal asm.js builds
  • Run validation in a child process with asm.js diagnostics enabled, so JavaScript fallback cannot hide validation or linking failures

The additional coercion does not change runtime behavior because b has already been converted with b = b | 0.

Test plan

  • Confirm the regression test fails for the unmodified 2.3.1 full and minimal asm.js bundles
  • Confirm the test passes for the patched full and minimal bundles
  • Run JavaScript syntax and diff checks
  • Run the complete chomp test matrix in CI with the Emscripten and Fastcomp toolchains

@Justineo
Justineo marked this pull request as ready for review August 2, 2026 15:17
@guybedford
guybedford enabled auto-merge (squash) August 9, 2026 17:52
@guybedford
guybedford merged commit 8274d03 into guybedford:main Aug 9, 2026
1 check passed
@Justineo
Justineo deleted the fix/asm-return-type branch August 10, 2026 03:14
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)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=es-module-lexer&package-manager=npm\_and\_yarn&previous-version=2.3.1&new-version=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)
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