summaryrefslogtreecommitdiff
path: root/module/language
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2024-09-25 17:27:17 +0200
committerAndy Wingo <wingo@pobox.com>2024-09-25 17:27:17 +0200
commit30c3849092b17a56b9b74dd23da121afc5076e08 (patch)
tree652ae55ecc0f68dd0ff7f8ac05c469e0535211a2 /module/language
parente45b70dcded37eb77e71ec30445b12040b6bb1b7 (diff)
downloadguile-30c3849092b17a56b9b74dd23da121afc5076e08.tar.gz
Tighten up range inference for scm->u64/truncate
* module/language/cps/types.scm (scm->u64/truncate): Better range analysis.
Diffstat (limited to 'module/language')
-rw-r--r--module/language/cps/types.scm8
1 files changed, 5 insertions, 3 deletions
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 512be4bb2..db4a8c7c8 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -1008,10 +1008,12 @@ minimum, and maximum."
(define! result &u64 param param))
(define-type-checker (scm->u64/truncate scm)
- (check-type scm &exact-integer &range-min &range-max))
+ (check-type scm &exact-integer -inf.0 +inf.0))
(define-type-inferrer (scm->u64/truncate scm result)
- (restrict! scm &exact-integer &range-min &range-max)
- (define! result &u64 0 &u64-max))
+ (restrict! scm &exact-integer -inf.0 +inf.0)
+ (if (<= 0 (&min scm) (&max scm) &u64-max)
+ (define! result &u64 (&min scm) (&max scm))
+ (define! result &u64 0 &u64-max)))
(define-type-checker (u64->scm u64)
#t)