From 8e816b0ad574a279b12a4d6622c6f224b67083b8 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 17 Dec 2020 18:01:10 +0100 Subject: [PATCH] Symplify type specifier (not t) as nil * lisp/emacs-lisp/comp-cstr.el (comp-cstr-intersection-no-mem): Add logic. * test/lisp/emacs-lisp/comp-cstr-tests.el (comp-cstr-typespec-tests-alist): Add two tests. --- lisp/emacs-lisp/comp-cstr.el | 9 +++++++++ test/lisp/emacs-lisp/comp-cstr-tests.el | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 3f3f4f61451..cd8f432412c 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -598,6 +598,15 @@ DST is returned." (valset dst) (valset neg) (range dst) (range neg) (neg dst) t) + + ;; (not t) => nil + (when (and (null (valset dst)) + (null (range dst)) + (neg dst) + (equal '(t) (typeset dst))) + (setf (typeset dst) () + (neg dst) nil)) + (cl-return-from comp-cstr-intersection-no-mem dst)) (when (cl-some diff --git a/test/lisp/emacs-lisp/comp-cstr-tests.el b/test/lisp/emacs-lisp/comp-cstr-tests.el index 03bf78968f2..f7ea00e86f2 100644 --- a/test/lisp/emacs-lisp/comp-cstr-tests.el +++ b/test/lisp/emacs-lisp/comp-cstr-tests.el @@ -195,7 +195,11 @@ ;; 77 ((and (or symbol string) (or number marker)) . nil) ;; 78 - ((and t t) . t)) + ((and t t) . t) + ;; 80 + ((and (or marker number) (integer 0 0)) . (integer 0 0)) + ;; 81 + ((and t (not t)) . nil)) "Alist type specifier -> expected type specifier.") (defmacro comp-cstr-synthesize-tests () -- 2.39.5