mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +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))
|
((and closed? (eqv? a-type &exact-integer) (eqv? b-type &exact-integer))
|
||||||
(define! result &exact-integer min* max*))
|
(define! result &exact-integer min* max*))
|
||||||
(else
|
(else
|
||||||
|
(let* ((type (logior a-type b-type))
|
||||||
;; Fractions may become integers.
|
;; Fractions may become integers.
|
||||||
(let ((type (logior a-type b-type)))
|
(type (if (zero? (logand type &fraction))
|
||||||
(define! result
|
|
||||||
(if (zero? (logand type &fraction))
|
|
||||||
type
|
type
|
||||||
(logior type &exact-integer))
|
(logior type &exact-integer)))
|
||||||
min* max*))))))
|
;; 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-simple-type-checker (add &number &number))
|
||||||
(define-type-aliases add add/immediate)
|
(define-type-aliases add add/immediate)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue