Repository navigation
A Nat crosses to a JS host as a plain number - #1506
Open
nicolas-abril wants to merge 1 commit into
Open
nicolas-abril wants to merge 1 commit into
nicolas-abril wants to merge 1 commit into
Conversation
The JS runtime has held Nats as numbers since 87a1e9c; only the host seam converted them to BigInt and back. js_marshal, js_host and nat_host are gone: an effect gets and answers a number, and an exported def takes and returns one, so the C and JS lanes agree on the value model. Deletes nat_host_neg (a negative host Nat was caught only by the marshal) and marshal_tag_unknown (the bendlang#1105 tag check ran only for types holding a Nat). Renames marshal_nat_bigint to marshal_nat_number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 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.
The JS runtime has held Nats as numbers since 87a1e9c (2.3x), and it kept BigInt only at the host seam. This PR removes that seam conversion. An effect's
.jsgets and answers a number, and a def exported through the.bendloader or-o x.mjstakes and returns one.js_marshal,js_host,nat_hostand themarshmemo are gone, which frees 1,163 ttok incomp.ts(63,929 → 62,766).Breaking for JS callers: a host that passed or expected
5nnow uses5. GUIDE.md, EFFECTS.md, main.ts's header,effs/now.jsand theapp_win_is_bug_2ddemo are updated. A Nat is still capped at 2^48-1 bynat_chk, so no value loses precision as a number.Tests
marshal_nat_bigint→marshal_nat_number.marshal_nat_pairandmarshal_native_formsnow expectnumber.marshal_array_depthandnat_host_boundsanswer numbers.nat_host_neg: a negative Nat answered by host code was caught only bynat_host. JS now runs it raw, the same way the C lane takes the host's word as is.marshal_tag_unknown: the JS lane: a Nat inside a value passed between two loaded .bend libraries stays a BigInt (constructor tags depend on the importing root), since 2.0.29 (still in 2.0.30) #1105 tag check lived insidejs_marshaland only ran for types that hold a Nat. The tag problem in JS lane: a Nat inside a value passed between two loaded .bend libraries stays a BigInt (constructor tags depend on the importing root), since 2.0.29 (still in 2.0.30) #1105 itself is unchanged.This also takes away the Nat half of #1105 and the return-type marshal behind #1150.
Validation
mainfor all 17 runtime benches.gates/perf.tsruns againstmain. Geomean compiler 0.992, runtime 0.999, no cell over 3%.🤖 Generated with Claude Code