summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2021-01-04 22:04:29 +0100
committerAndrea Corallo <akrl@sdf.org>2021-01-04 22:31:40 +0100
commit5074447ef4980e2eb613e908e346fd3471f52139 (patch)
treec6d1f26b0527843bd85053e443567c6552988a76 /lisp/emacs-lisp
parenta3f2373bfb604af5570c86b4ffefb23296a5bfdd (diff)
downloademacs-5074447ef4980e2eb613e908e346fd3471f52139.tar.gz
emacs-5074447ef4980e2eb613e908e346fd3471f52139.tar.bz2
emacs-5074447ef4980e2eb613e908e346fd3471f52139.zip
Fix type inference for bug#45635
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem): Fix missing mixed pos neg handling. * test/lisp/emacs-lisp/comp-cstr-tests.el (comp-cstr-typespec-tests-alist): Add a test. * test/src/comp-tests.el (45635): New testcase. * test/src/comp-test-funcs.el (comp-test-45635-f): New function.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/comp-cstr.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index e63afa16a23..651c7b7931e 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -558,6 +558,22 @@ DST is returned."
;; "simple" for now.
(give-up))
+ ;; When every neg type is a subtype of some pos one.
+ ;; In case return pos.
+ (when (and (typeset neg)
+ (cl-every (lambda (x)
+ (cl-some (lambda (y)
+ (comp-subtype-p x y))
+ (append (typeset pos)
+ (when (range pos)
+ '(integer)))))
+ (typeset neg)))
+ (setf (typeset dst) (typeset pos)
+ (valset dst) (valset pos)
+ (range dst) (range pos)
+ (neg dst) nil)
+ (cl-return-from comp-cstr-union-1-no-mem dst))
+
;; Verify disjoint condition between positive types and
;; negative types coming from values, in case give-up.
(let ((neg-value-types (nconc (mapcar #'type-of (valset neg))