Skip to content

Throw on BigInt division by zero#2778

Merged
proggeramlug merged 2 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-2755-bigint-zero-div
May 30, 2026
Merged

Throw on BigInt division by zero#2778
proggeramlug merged 2 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-2755-bigint-zero-div

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Closes #2755.

Summary:

  • Make js_bigint_div and js_bigint_mod throw a catchable RangeError: Division by zero when the divisor is 0n.
  • Keep normal BigInt / truncation and % sign-of-dividend behavior unchanged.
  • Add focused parity coverage for literal and variable zero divisors, plus nonzero control cases.

Validation after rebasing on current origin/main:

  • PATH="/root/.npm/_npx/8758e404b5eed2f3/node_modules/.bin:$PATH" node test-parity/node-suite/bigint/arithmetic/division-by-zero.ts
  • env RUSTC_WRAPPER= PATH="/root/.npm/_npx/8758e404b5eed2f3/node_modules/.bin:$PATH" ./run_parity_tests.sh --suite node-suite --module bigint --filter division-by-zero (report test-parity/reports/parity_report_20260529_231423.json)
  • env RUSTC_WRAPPER= cargo test -p perry-runtime bigint
  • env RUSTC_WRAPPER= cargo check -p perry-runtime
  • cargo fmt --all -- --check
  • git diff --check
  • jq empty test-parity/known_failures.json test-parity/threshold.json
  • ./scripts/check_file_size.sh

Pre-fix reproduction:

  • ./run_parity_tests.sh --suite node-suite --module bigint --filter division-by-zero failed with Perry printing div literal zero ok 0 while Node printed div literal zero throw RangeError Division by zero true (report test-parity/reports/parity_report_20260529_230604.json).

@proggeramlug proggeramlug merged commit c08da3b into PerryTS:main May 30, 2026
11 checks passed
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.

runtime: throw RangeError for BigInt division and remainder by zero

2 participants