From f61870979c38bcdba48b3c28d748a3e17c1a7d3f Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 17 Jan 2016 16:58:36 +0100 Subject: [PATCH] Fix type inference of integer division * module/language/cps/types.scm (define-binary-result!): Fix inference of integer division. --- module/language/cps/types.scm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm index a58953d55..4adb8a89e 100644 --- a/module/language/cps/types.scm +++ b/module/language/cps/types.scm @@ -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)