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:
parent
ee85113f4a
commit
f61870979c
1 changed files with 11 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue