Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch "divide by zero" in more places in the primitive evaluator #2817

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leonschoorl
Copy link
Member

This fixes the exact problem encountered in #2815.

But there are still other places in the evaluator that still need some more work:

  • [quot,rem][Int,Word][8,16,32,64]#: when presented with 0 divisors these don't throw normal Haskell exception, but some lower level exception that just kills the haskell process.
    So we should just check that the divisor isn't zero instead of trying to catch exceptions, possibly for all of them.
    Also this needs a some refactoring as we currently don't have direct access to the arguments, because how the evaluation is defined via the lift* functions.
  • quoteRem*: these all output tuples with two numbers, some of them make calls to catchDivByZero, but per output number.
    This isn't correct, because when catchDivByZero catches a division by zero, it'll put in an undefined with the type of the full result.
    So you and up with something like quotRemInt 3 0 evaluating to:
    ( undefined :: (Int,Int), undefined :: (Int,Int) ) :: (Int,Int)

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

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