Skip to content

Commit 7ca54f6

Browse files
authored
Fix type of (- x) (#1004)
cptypes was just copying the type from x to (- x). Use predicate-close/plus to get a closed set that includes the result.
1 parent 28d8210 commit 7ca54f6

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

mats/cptypes.ms

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,9 @@
12511251
(not (cptypes-equivalent-expansion? ; integer? is not closed
12521252
'(lambda (x y) (when (and (integer? x) (integer? y)) (integer? (- x y))))
12531253
'(lambda (x y) (when (and (integer? x) (integer? y)) (- x y) #t))))
1254+
(not (cptypes-equivalent-expansion?
1255+
'(lambda (x y) (when (fixnum? x) (fixnum? (- x))))
1256+
'(lambda (x y) (when (fixnum? x) #t))))
12541257
(cptypes-equivalent-expansion?
12551258
'(lambda (x y) (when (and (fixnum? x) (fixnum? y))
12561259
(- x y)))

release_notes/release_notes.stex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ even if the result is known in case of a success.
143143
The type recovery pass has improved support for \scheme{exact}, \scheme{inexact},
144144
and similar functions.
145145

146+
A bug that incorrectly determined the type of \scheme{(- x)} has been fixed.
147+
146148
\subsection{In-place vector copying (10.3.0)}
147149

148150
The \scheme{vector-copy!} procedure copies a subsequence

s/cptypes.ss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,10 @@ Notes:
12841284

12851285
(define-specialize 2 -
12861286
[(x) (values `(call ,preinfo ,pr ,x)
1287-
(predicate-intersect (get-type x) number-pred) ntypes #f #f)]
1287+
(predicate-close/plus (list `(quote 0)
1288+
(predicate-intersect (get-type x) number-pred))
1289+
pr)
1290+
ntypes #f #f)]
12881291
[x* ; x* has at least 2 arguments
12891292
(let* ([r* (get-type x*)]
12901293
[ret (predicate-close/plus

0 commit comments

Comments
 (0)