From e0f20da6ecd1fceabdce480dd878be293cfba027 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Fri, 18 Dec 2020 17:22:05 +0100 Subject: [PATCH] Simplify correctly (or (integer 1 1) (not (integer 1 1))) as t * lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem): Logic update. * test/lisp/emacs-lisp/comp-cstr-tests.el (comp-cstr-typespec-tests-alist): Add a test. --- lisp/emacs-lisp/comp-cstr.el | 17 +++++++++++------ test/lisp/emacs-lisp/comp-cstr-tests.el | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index a1722035963..22d3958aed3 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -474,12 +474,17 @@ DST is returned." (cl-nset-difference (valset neg) (valset pos))))) ;; Range propagation - (setf (range neg) - (when range - (comp-range-negation - (comp-range-union - (comp-range-negation (range neg)) - (range pos))))) + (when range + ;; Handle apart (or (integer 1 1) (not (integer 1 1))) + ;; like cases. + (if (and (range pos) (range neg) + (equal (range pos) (range neg))) + (give-up) + (setf (range neg) + (comp-range-negation + (comp-range-union + (comp-range-negation (range neg)) + (range pos)))))) (if (comp-cstr-empty-p neg) (setf (typeset dst) (typeset pos) diff --git a/test/lisp/emacs-lisp/comp-cstr-tests.el b/test/lisp/emacs-lisp/comp-cstr-tests.el index f7ea00e86f2..b38573ca33a 100644 --- a/test/lisp/emacs-lisp/comp-cstr-tests.el +++ b/test/lisp/emacs-lisp/comp-cstr-tests.el @@ -199,7 +199,9 @@ ;; 80 ((and (or marker number) (integer 0 0)) . (integer 0 0)) ;; 81 - ((and t (not t)) . nil)) + ((and t (not t)) . nil) + ;; 82 + ((or (integer 1 1) (not (integer 1 1))) . t)) "Alist type specifier -> expected type specifier.") (defmacro comp-cstr-synthesize-tests () -- 2.39.5