[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 949dd41: Fix mistake in switch-case generation of `null` (bug#497
From: |
Mattias Engdegård |
Subject: |
master 949dd41: Fix mistake in switch-case generation of `null` (bug#49746) |
Date: |
Tue, 27 Jul 2021 11:43:49 -0400 (EDT) |
branch: master
commit 949dd41c31dab69f7a5067bba324c28bb2cfbf8e
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Fix mistake in switch-case generation of `null` (bug#49746)
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 | 3 ++-
test/lisp/emacs-lisp/bytecomp-tests.el | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index f615006..1b64a06 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -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))
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 7c40f7e..ee0f931 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -503,6 +503,12 @@
(: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.")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 949dd41: Fix mistake in switch-case generation of `null` (bug#49746),
Mattias Engdegård <=