Skip to content

fix(rational): reject zero denominator in div and reciprocal - #290

Open
kokic wants to merge 1 commit into
mainfrom
fix-266
Open

fix(rational): reject zero denominator in div and reciprocal#290
kokic wants to merge 1 commit into
mainfrom
fix-266

Conversation

@kokic

@kokic kokic commented Aug 4, 2026

Copy link
Copy Markdown

Dividing by zero or taking the reciprocal of zero previously produced an invalid 1/0 value. Panic with a clear message at both call sites, and guard op_div / reciprocal as a defense-in-depth invariant check. Add panic regression tests for both cases.

#266

@kokic
kokic requested review from myfreess and a lite review from Copilot August 4, 2026 07:55

This comment was marked as outdated.

Dividing by zero or taking the reciprocal of zero previously produced an
invalid 1/0 value via new_unchecked. Both operators now panic with a clear
message, and div_checked/reciprocal_checked raise RationalError for callers
that want to handle the failure. Add regression tests for both cases.

This comment was marked as low quality.

This comment was marked as low quality.

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