Skip to content

Commit

Permalink
Don't simplify _/(x, 0)_ and _%(x, 0)_
Browse files Browse the repository at this point in the history
Closes #25.
  • Loading branch information
hirrolot committed Nov 27, 2024
1 parent 70aa893 commit d383de1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## unreleased

### Fixed

- Do not simplify _/(x, 0)_ and _%(x, 0)_ to avoid incorrect panic messages (issue https://github.com/mazeppa-dev/mazeppa/issues/25).

## 0.4.3 - 2024-11-11

### Changed
Expand Down
3 changes: 0 additions & 3 deletions lib/mechanics/simplifier.ml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ let handle_op2 ~(op : Symbol.t) : t * t -> t = function
| Var _x, Const (Const.Int n) when op = symbol "%" && is_one n ->
let (module Singleton) = Checked_oint.singleton n in
int Singleton.(to_generic zero)
(* /(x, 0), %(x, 0) -> out of range *)
| Var _x, Const (Const.Int n) when (op = symbol "/" || op = symbol "%") && is_zero n ->
do_int_op2 ~op (Checked_oint.pair_exn (n, n))
(* |(x, x), &(x, x) -> x *)
| (Var x as t), Var y when (op = symbol "|" || op = symbol "&") && x = y -> t
(* =(x, x), >=(x, x), <=(x, x) -> T() *)
Expand Down

0 comments on commit d383de1

Please sign in to comment.