Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.

fix(falcon): add missing return in Polynomial::div for zero numerator - #1106

Open
Sertug17 wants to merge 1 commit into
0xMiden:nextfrom
Sertug17:fix/polynomial-div-missing-return
Open

fix(falcon): add missing return in Polynomial::div for zero numerator#1106
Sertug17 wants to merge 1 commit into
0xMiden:nextfrom
Sertug17:fix/polynomial-div-missing-return

Conversation

@Sertug17

Copy link
Copy Markdown

Summary

Fixes 0xMiden/miden-vm#3534

Polynomial::div discards the result of Self::zero() when the numerator is zero because the return keyword is missing. Execution falls through to the division loop where remainder.degree().unwrap() panics on None.

Fix

// Before (bug)
if self.is_zero() {
    Self::zero();  // result discarded, no return
}

// After
if self.is_zero() {
    return Self::zero();
}

Testing

Dividing a zero polynomial by a non-zero polynomial now returns zero instead of panicking.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Automated check (CONTRIBUTING.md)

Findings:

Recommendations:

  • Consider adding a Test plan or clear review steps.

Next steps:

@Sertug17

Copy link
Copy Markdown
Author

/quality-review

The automated check flagged this as trivial. I'll add a regression test for zero numerator division. Pushing shortly.

@Sertug17
Sertug17 force-pushed the fix/polynomial-div-missing-return branch from 8a8578b to 8c8fe3c Compare July 31, 2026 19:27
Polynomial::div discards the result of Self::zero() when the numerator
is zero because the return keyword is missing. Execution falls through
to the division loop where remainder.degree().unwrap() panics on None.

Fixes #1105
@Sertug17
Sertug17 force-pushed the fix/polynomial-div-missing-return branch from 8c8fe3c to 104d4a6 Compare July 31, 2026 19:29
@Sertug17

Copy link
Copy Markdown
Author

/quality-review

Added a regression test (div_zero_numerator_returns_zero) that verifies zero divided by non-zero returns zero instead of panicking. Force-pushed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: missing return in Polynomial::div causes panic on zero numerator

1 participant