emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a71de4b52d: Improve check for misleading 'cl-case' cases (Bug#579


From: Philipp Stephani
Subject: master a71de4b52d: Improve check for misleading 'cl-case' cases (Bug#57915).
Date: Mon, 19 Sep 2022 07:37:33 -0400 (EDT)

branch: master
commit a71de4b52d3de14349ded7d88c4cae6e2a9376ae
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    Improve check for misleading 'cl-case' cases (Bug#57915).
    
    * lisp/emacs-lisp/cl-macs.el (cl-case): Check that the case is of the
    form (quote FOO), not just (quote).
    * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-no-warning): New unit test.
---
 lisp/emacs-lisp/cl-macs.el            |  2 +-
 test/lisp/emacs-lisp/cl-macs-tests.el | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 5d330f32d6..beafee1d63 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -792,7 +792,7 @@ compared by `eql'.
                           (macroexp-warn-and-return
                            "Case nil will never match"
                            nil 'suspicious))
-                         ((and (consp (car c)) (not (cddar c))
+                         ((and (consp (car c)) (cdar c) (not (cddar c))
                                (memq (caar c) '(quote function)))
                           (macroexp-warn-and-return
                            (format-message
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el 
b/test/lisp/emacs-lisp/cl-macs-tests.el
index 83928775f1..f742637ee3 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -792,4 +792,15 @@ constructs."
                                               (should (equal messages
                                                              (concat "Warning: 
" message "\n"))))))))))
 
+(ert-deftest cl-case-no-warning ()
+  "Test that `cl-case' and `cl-ecase' don't warn in some valid cases.
+See Bug#57915."
+  (dolist (case '(quote (quote) function (function)))
+    (dolist (macro '(cl-case cl-ecase))
+      (let ((form `(,macro val (,case 1))))
+        (ert-info ((prin1-to-string form) :prefix "Form: ")
+          (ert-with-message-capture messages
+            (macroexpand form)
+            (should (string-empty-p messages))))))))
+
 ;;; cl-macs-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]