Skip to content

bigint: range checks and exact **; namespace retry generated functions twice - #728

Merged
ASDAlexander77 merged 1 commit into
mainfrom
bigint-number-fixes
Oct 29, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
bigint-number-fixes

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

  • bigint range checks: x / 0n and x % 0n were a hardware fault, and x ** -1n gave 1n. Both now stop the program with TypeScript's RangeError message ("Division by zero", "Exponent must be non-negative"), as an invalid array length does (Array length is unchecked: a negative or huge length= crashes or gives a wrong length, and failed allocations are not detected #483).
  • exact bigint **: an integer ** is lowered to exponentiation by squaring; through math.powf, 2n ** 62n was rounded.
  • namespace retry: a namespace whose function names a class declared after it failed with "redefinition of symbol". The retry cleared which of its statements were already generated, so they were generated again. The real pass now keeps them; a dummy run still clears them all.

The DefaultLib side (Number.toString returning nothing, and radix conversion) is in the companion DefaultLib PR; the two are independent.

Tests

  • 00bigint_ops.ts: powers past 2^53, (-3n) ** 3n, **=
  • bigint-range/{division,remainder,power}.ts × gc/rc/none/own: the message after the output printed before it
  • 00namespace_forward_class.ts
  • Windows: ctest 6235/6235; DefaultLib gc 178, rc/none 177 (+1 skipped), own 167 (+11 skipped)

🤖 Generated with Claude Code

…ed functions twice

- A bigint divided by 0n (a hardware fault) or raised to a negative power (1n) stops the
  program with TypeScript's RangeError message, as an invalid array length does (#483).
- `**` of two bigints is an integer power by squaring in the lowering: through math.powf
  `2n ** 62n` was rounded.
- A namespace whose function names a class declared after it is retried once the class is
  there: the retry cleared which of its statements were generated, so the ones the first
  try had made were generated again ("redefinition of symbol"). The real pass keeps them;
  a dummy run still clears them all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 5a142b1 into main Oct 29, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the bigint-number-fixes branch October 29, 2026 01:13
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.

1 participant