]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/comp.el (comp-common-supertype-2): Fix null intersection
authorAndrea Corallo <akrl@sdf.org>
Sat, 7 Nov 2020 20:00:14 +0000 (21:00 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sat, 7 Nov 2020 20:11:39 +0000 (21:11 +0100)
lisp/emacs-lisp/comp.el

index 9fbf60c96c26d408e23919e3c743ffba63b17fdc..c837e020603fe6d6ca6b2526464b476855d749fd 100644 (file)
@@ -2155,14 +2155,13 @@ PRE-LAMBDA and POST-LAMBDA are called in pre or post-order if non-nil."
 
 (defun comp-common-supertype-2 (type1 type2)
   "Return the first common supertype of TYPE1 TYPE2."
-  (car (cl-reduce (lambda (x y)
-                    (if (> (cdr x) (cdr y))
-                        x
-                      y))
-                  (cl-intersection
-                   (comp-supertypes type1)
-                   (comp-supertypes type2)
-                   :key #'car))))
+  (when-let ((types (cl-intersection
+                     (comp-supertypes type1)
+                     (comp-supertypes type2)
+                     :key #'car)))
+    (car (cl-reduce (lambda (x y)
+                      (if (> (cdr x) (cdr y)) x y))
+                    types))))
 
 (defun comp-common-supertype (&rest types)
   "Return the first common supertype of TYPES."