1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Fix type inference of integer division

* module/language/cps/types.scm (define-binary-result!): Fix inference
  of integer division.
This commit is contained in:
Andy Wingo 2016-01-17 16:58:36 +01:00
parent ee85113f4a
commit f61870979c

View file

@ -978,13 +978,17 @@ minimum, and maximum."
((and closed? (eqv? a-type &exact-integer) (eqv? b-type &exact-integer))
(define! result &exact-integer min* max*))
(else
;; Fractions may become integers.
(let ((type (logior a-type b-type)))
(define! result
(if (zero? (logand type &fraction))
type
(logior type &exact-integer))
min* max*))))))
(let* ((type (logior a-type b-type))
;; Fractions may become integers.
(type (if (zero? (logand type &fraction))
type
(logior type &exact-integer)))
;; Integers may become fractions under division.
(type (if (or closed?
(zero? (logand type (logior &exact-integer))))
type
(logior type &fraction))))
(define! result type min* max*))))))
(define-simple-type-checker (add &number &number))
(define-type-aliases add add/immediate)