]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix `=' propagation to handle -0.0 0.0 case
authorAndrea Corallo <akrl@sdf.org>
Sat, 6 Mar 2021 19:38:00 +0000 (20:38 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sat, 6 Mar 2021 19:38:00 +0000 (20:38 +0100)
* lisp/emacs-lisp/comp-cstr.el
(comp-cstr-intersection-homogeneous): Fix indent + use `memql'.
(comp-cstr-=): Handle 0.0 -0.0 idiosyncrasy
* test/src/comp-tests.el (comp-tests-type-spec-tests): Add two
tests and fix enumeration.

lisp/emacs-lisp/comp-cstr.el
test/src/comp-tests.el

index 6a8ec5213d54b8b396c3c6798a6e6482994fd7b0..d6423efa0d6bbb0dc4af862fbb4851f864b1e591 100644 (file)
@@ -664,7 +664,7 @@ DST is returned."
       (cl-return-from comp-cstr-intersection-homogeneous dst))
 
     (setf (neg dst) (when srcs
-                                (neg (car srcs))))
+                      (neg (car srcs))))
 
     ;; Type propagation.
     (setf (typeset dst)
@@ -682,7 +682,7 @@ DST is returned."
              ;; If (member value) is subtypep of all other sources then
              ;; is good to be colleted.
              when (cl-every (lambda (s)
-                              (or (memq val (valset s))
+                              (or (memql val (valset s))
                                   (cl-some (lambda (type)
                                              (cl-typep val type))
                                            (typeset s))))
@@ -890,6 +890,10 @@ Non memoized version of `comp-cstr-intersection-no-mem'."
                       (cl-return cstr)
                  finally (setf (valset cstr)
                                (append vals-to-add (valset cstr))))
+                (when (memql 0.0 (valset cstr))
+                  (cl-pushnew -0.0 (valset cstr)))
+                (when (memql -0.0 (valset cstr))
+                  (cl-pushnew 0.0 (valset cstr)))
                 cstr))
       (comp-cstr-intersection dst (relax-cstr op1) (relax-cstr op2)))))
 
index dae2abca7e7642d4123417cda906ce35dc1f0b79..cd1c2e0735e74e8475320ec2ed44af393edafad0 100644 (file)
@@ -1299,32 +1299,48 @@ Return a list of results."
           (error "")))
        cons)
 
-      ;; 69
+      ;; 68
       ((defun comp-tests-ret-type-spec-f (x)
         (if (and (floatp x)
-                 (= x 0))
+                 (= x 1))
              x
            (error "")))
        ;; Conservative (see cstr relax in `comp-cstr-=').
-       (or (member 0.0) (integer 0 0)))
+       (or (member 1.0) (integer 1 1)))
 
-      ;; 70
+      ;; 69
       ((defun comp-tests-ret-type-spec-f (x)
         (if (and (integer x)
-                 (= x 0))
+                 (= x 1))
              x
            (error "")))
        ;; Conservative (see cstr relax in `comp-cstr-=').
-       (or (member 0.0) (integer 0 0)))
+       (or (member 1.0) (integer 1 1)))
 
-      ;; 71
+      ;; 70
       ((defun comp-tests-ret-type-spec-f (x y)
         (if (and (floatp x)
                  (integerp y)
                  (= x y))
              x
            (error "")))
-       (or float integer))))
+       (or float integer))
+
+      ;; 71
+      ((defun comp-tests-ret-type-spec-f (x)
+         (if (= x 0.0)
+             x
+           (error "")))
+       (or (member -0.0 0.0) (integer 0 0)))
+
+      ;; 72
+      ((defun comp-tests-ret-type-spec-f (x)
+         (unless (= x 0.0)
+           (error ""))
+         (unless (eql x -0.0)
+           (error ""))
+         x)
+       float)))
 
   (defun comp-tests-define-type-spec-test (number x)
     `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) ()