summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2021-02-17 21:45:37 +0100
committerAndrea Corallo <akrl@sdf.org>2021-02-17 22:03:41 +0100
commit1fe5994bcb8b58012dbba0a5f7d03138c293286f (patch)
tree255fa560db8547ea2d2174bbeb69ee4482f0885a
parent0d7c893203087d60f0ce549521f4c715c87a7038 (diff)
downloademacs-1fe5994bcb8b58012dbba0a5f7d03138c293286f.tar.gz
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.
-rw-r--r--lisp/emacs-lisp/comp-cstr.el8
-rw-r--r--test/src/comp-tests.el29
2 files changed, 32 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 1afb928e10c..3c00b68d0f6 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 c0325a8d5df..08c18894419 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)) ()