From: Stefan Monnier Date: Thu, 17 Mar 2022 14:07:35 +0000 (-0400) Subject: * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn suspicious args X-Git-Tag: emacs-29.0.90~1931^2~1063 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=693484d36b1326aebd895314570167ca8da87d69;p=emacs.git * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn suspicious args --- diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index b44dda6f9d4..7b11c0c8159 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.