Skip to content

fix(js): explain the host Nat input range - #1656

Merged
Lorenzobattistela merged 3 commits into
bendlang:mainfrom
oxura:fix/1634-host-nat-diagnostic-20261017
Oct 19, 2026
Merged

Lorenzobattistela merged 3 commits into
bendlang:mainfrom
oxura:fix/1634-host-nat-diagnostic-20261017

Conversation

@oxura

@oxura oxura commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1634.

Invalid JavaScript Nat inputs reported the 2^48-1 arithmetic limit, even for a negative number, fraction, BigInt, NaN or Infinity. nat_in now throws its own message, bend: expected a Nat host number: an integer from 0 to 2^53. The accepted range and the arithmetic limit are unchanged.

Tests:

  • tests/io/nat_host_export: the exported-argument rejections (one call and curried, plus NaN/Infinity) check the exact new message; 0, 2^48 and 2^53 round-trip through identity.
  • tests/io/nat_host_neg: a foreign effect answering -3 is now a JS-only golden with the new message. The C lane reads that answer as a word past the cap and fail-stops later in Nat.show with the 2^48-1 limit, so the two lanes cannot share one golden; the C twin is removed.

@Lorenzobattistela Lorenzobattistela self-assigned this Oct 19, 2026
Lorenzobattistela and others added 2 commits October 19, 2026 08:55
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The export test checks the exact host-range error again, and
nat_host_neg.bend stays a golden test on the JS lane, where the answer is
rejected as it comes in. The C lane fail-stops later with the 2^48-1
limit, so its twin goes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lorenzobattistela
Lorenzobattistela merged commit d317471 into bendlang:main Oct 19, 2026
1 check passed
nicolas-abril added a commit to nicolas-abril/bend that referenced this pull request Oct 19, 2026
bendlang#1438's tail-drop spine and bendlang#1447's device rounds come in as written. The
constructor table takes bendlang#1438's Cid struct with this branch's nat flag
(a foreign Nat answer checked as it comes in) as one more byte; lay_holds
keys by ty_key. tests/io/nat_host_neg takes bendlang#1656's JS-only form.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lorenzobattistela Lorenzobattistela mentioned this pull request Oct 20, 2026
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.

fix(js): invalid Nat inputs report a misleading 2^48-1 limit

2 participants