guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/10: Fix type inference of integer division


From: Andy Wingo
Subject: [Guile-commits] 01/10: Fix type inference of integer division
Date: Mon, 01 Feb 2016 14:35:29 +0000

wingo pushed a commit to branch master
in repository guile.

commit f61870979c38bcdba48b3c28d748a3e17c1a7d3f
Author: Andy Wingo <address@hidden>
Date:   Sun Jan 17 16:58:36 2016 +0100

    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 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index a58953d..4adb8a8 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]