[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 693484d36b: * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn
From: |
Stefan Monnier |
Subject: |
master 693484d36b: * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn suspicious args |
Date: |
Thu, 17 Mar 2022 10:07:44 -0400 (EDT) |
branch: master
commit 693484d36b1326aebd895314570167ca8da87d69
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn suspicious args
---
lisp/emacs-lisp/cl-generic.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index b44dda6f9d..7b11c0c815 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -262,6 +262,16 @@ DEFAULT-BODY, if present, is used as the body of a default
method.
(declarations nil)
(methods ())
(options ())
+ (warnings
+ (let ((nonsymargs
+ (delq nil (mapcar (lambda (arg) (unless (symbolp arg) arg))
+ args))))
+ (when nonsymargs
+ (list
+ (macroexp-warn-and-return
+ (format "Non-symbol arguments to cl-defgeneric: %s"
+ (mapconcat #'prin1-to-string nonsymargs ""))
+ nil nil nil nonsymargs)))))
next-head)
(while (progn (setq next-head (car-safe (car options-and-methods)))
(or (keywordp next-head)
@@ -284,6 +294,7 @@ DEFAULT-BODY, if present, is used as the body of a default
method.
(setq name (gv-setter (cadr name))))
`(prog1
(progn
+ ,@warnings
(defalias ',name
(cl-generic-define ',name ',args ',(nreverse options))
,(if (consp doc) ;An expression rather than a constant.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 693484d36b: * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn suspicious args,
Stefan Monnier <=