emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 1fe5994: Fix inverted logic in constraint comparison


From: Andrea Corallo
Subject: feature/native-comp 1fe5994: Fix inverted logic in constraint comparison (bug#46540)
Date: Wed, 17 Feb 2021 16:08:09 -0500 (EST)

branch: feature/native-comp
commit 1fe5994bcb8b58012dbba0a5f7d03138c293286f
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Fix inverted logic in constraint comparison (bug#46540)
    
        * lisp/emacs-lisp/comp-cstr.el (comp-cstr->, comp-cstr->=)
        (comp-cstr-<, comp-cstr-<=): Fix inverted logic.
        * test/src/comp-tests.el (comp-tests-type-spec-tests): Add
        three integer constrain tests.
---
 lisp/emacs-lisp/comp-cstr.el |  8 ++++----
 test/src/comp-tests.el       | 29 ++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 1afb928..3c00b68 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -791,7 +791,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((,(1+ src) . +))
              (when-let* ((range (range src))
-                         (low (comp-cstr-greatest-in-range range))
+                         (low (comp-cstr-smallest-in-range range))
                          (okay (integerp low)))
                `((,(1+ low) . +))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
@@ -804,7 +804,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((,src . +))
              (when-let* ((range (range src))
-                         (low (comp-cstr-greatest-in-range range))
+                         (low (comp-cstr-smallest-in-range range))
                          (okay (integerp low)))
                `((,low . +))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
@@ -817,7 +817,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((- . ,(1- src)))
              (when-let* ((range (range src))
-                         (low (comp-cstr-smallest-in-range range))
+                         (low (comp-cstr-greatest-in-range range))
                          (okay (integerp low)))
                `((- . ,(1- low)))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
@@ -830,7 +830,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((- . ,src))
              (when-let* ((range (range src))
-                         (low (comp-cstr-smallest-in-range range))
+                         (low (comp-cstr-greatest-in-range range))
                          (okay (integerp low)))
                `((- . ,low))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index c0325a8..08c1889 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -1211,7 +1211,34 @@ Return a list of results."
                     (= x 3))
            (error "Not foo or 3"))
          x)
-       (or (member foo) (integer 3 3)))))
+       (or (member foo) (integer 3 3)))
+
+      ;;58
+      ((defun comp-tests-ret-type-spec-f (x y)
+         (if (and (natnump x)
+                  (natnump y)
+                  (<= x y))
+             x
+           (error "")))
+       (integer 0 *))
+
+      ;; 59
+      ((defun comp-tests-ret-type-spec-f (x y)
+         (if (and (>= x 3)
+                  (<= y 10)
+                  (<= x y))
+             x
+           (error "")))
+       (or float (integer 3 10)))
+
+      ;; 60
+      ((defun comp-tests-ret-type-spec-f (x y)
+                   (if (and (<= x 10)
+                            (>= y 3)
+                            (>= x y))
+             x
+           (error "")))
+       (or float (integer 3 10)))))
 
   (defun comp-tests-define-type-spec-test (number x)
     `(comp-deftest ,(intern (format "ret-type-spec-%d" number)) ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]