]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix mistake in switch-case generation of `null` (bug#49746)
authorMattias Engdegård <mattiase@acm.org>
Tue, 27 Jul 2021 15:26:26 +0000 (17:26 +0200)
committerMattias Engdegård <mattiase@acm.org>
Tue, 27 Jul 2021 15:32:23 +0000 (17:32 +0200)
Reported by Gregor Zattler.

* lisp/emacs-lisp/bytecomp.el (byte-compile--cond-switch-prefix):
Be more careful in the selection of equality.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test case.

lisp/emacs-lisp/bytecomp.el
test/lisp/emacs-lisp/bytecomp-tests.el

index f6150069e81dc7bac213b63c032a956f85aae335..1b64a06fe42c8ec127e652cee43f5ce46833200d 100644 (file)
@@ -4362,7 +4362,8 @@ Return (TAIL VAR TEST CASES), where:
               (and (or (eq var switch-var) (not switch-var))
                    (progn
                      (setq switch-var var)
-                     (setq switch-test 'eq)
+                     (setq switch-test
+                           (byte-compile--common-test switch-test 'eq))
                      (unless (memq nil keys)
                        (push nil keys)
                        (push (cons (list nil) (or body '(t))) cases))
index 7c40f7ebca3b8c3913226e14269096648ac47b0f..ee0f931c192ff72ae1d2b141d8276848b9f9a863 100644 (file)
                  (:success 'good))
                (1+ x))))
       (funcall f 3))
+
+    ;; Check `not' in cond switch (bug#49746).
+    (mapcar (lambda (x) (cond ((equal x "a") 1)
+                              ((member x '("b" "c")) 2)
+                              ((not x) 3)))
+            '("a" "b" "c" "d" nil))
     )
   "List of expressions for cross-testing interpreted and compiled code.")