mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Signal an error if a fallback cl-case is misplaced
* lisp/emacs-lisp/cl-macs.el (cl-case): Warn if the user passes a nil key list (which would never match). Warn about quoted symbols that should probably be unquoted. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-warning): New unit test (bug#51368).
This commit is contained in:
parent
07ee1be052
commit
6d8f5161ea
2 changed files with 18 additions and 2 deletions
|
|
@ -747,4 +747,15 @@ collection clause."
|
|||
;; Just make sure the forms can be instrumented.
|
||||
(eval-buffer))))
|
||||
|
||||
(ert-deftest cl-case-error ()
|
||||
"Test that `cl-case' and `cl-ecase' signal an error if a t or
|
||||
`otherwise' key is misplaced."
|
||||
(dolist (form '((cl-case val (t 1) (123 2))
|
||||
(cl-ecase val (t 1) (123 2))
|
||||
(cl-ecase val (123 2) (t 1))))
|
||||
(ert-info ((prin1-to-string form) :prefix "Form: ")
|
||||
(let ((error (should-error (macroexpand form))))
|
||||
(should (equal (cdr error)
|
||||
'("Misplaced t or `otherwise' clause")))))))
|
||||
|
||||
;;; cl-macs-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue