summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2022-10-16 12:01:47 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2022-10-16 12:01:47 -0400
commit13d6e8fa54843b0b087e5a9c266e4b7e0d709c3f (patch)
tree1c09984f5d78c711416d7748bf83051789a0ac00 /lisp/subr.el
parent0e5fc2345d8ec72fd8f7ad51ce1e42040e0e91da (diff)
downloademacs-13d6e8fa54843b0b087e5a9c266e4b7e0d709c3f.tar.gz
emacs-13d6e8fa54843b0b087e5a9c266e4b7e0d709c3f.tar.bz2
emacs-13d6e8fa54843b0b087e5a9c266e4b7e0d709c3f.zip
cl-generic: Fix `advertised-calling-convention` declarations
* lisp/emacs-lisp/cl-generic.el (cl-generic-define-method): Preserve the `advertised-calling-convention`, if any (bug#58563). * lisp/subr.el (declare): Warn when we hit this. * lisp/emacs-lisp/byte-run.el (get-advertised-calling-convention): New fun. * lisp/progmodes/elisp-mode.el (elisp-get-fnsym-args-string): * lisp/help-fns.el (help-fns--signature): * lisp/emacs-lisp/bytecomp.el (byte-compile-fdefinition): Use it. * test/lisp/emacs-lisp/cl-generic-tests.el (cl-generic-tests--acc): New fun. (cl-generic-tests--advertised-calling-convention-bug58563): New test.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 56ce9fa69b9..08dfe7aa430 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -344,7 +344,7 @@ in compilation warnings about unused variables.
;; FIXME: This let often leads to "unused var" warnings.
`((let ((,var ,counter)) ,@(cddr spec)))))))
-(defmacro declare (&rest _specs)
+(defmacro declare (&rest specs)
"Do not evaluate any arguments, and return nil.
If a `declare' form appears as the first form in the body of a
`defun' or `defmacro' form, SPECS specifies various additional
@@ -355,8 +355,16 @@ The possible values of SPECS are specified by
`defun-declarations-alist' and `macro-declarations-alist'.
For more information, see info node `(elisp)Declare Form'."
- ;; FIXME: edebug spec should pay attention to defun-declarations-alist.
- nil)
+ ;; `declare' is handled directly by `defun/defmacro' rather than here.
+ ;; If we get here, it's because there's a `declare' somewhere not attached
+ ;; to a `defun/defmacro', i.e. a `declare' which doesn't do what it's
+ ;; intended to do.
+ (let ((form `(declare . ,specs))) ;; FIXME: WIBNI we had &whole?
+ (macroexp-warn-and-return
+ (format-message "Stray `declare' form: %S" form)
+ ;; Make a "unique" harmless form to circumvent
+ ;; the cache in `macroexp-warn-and-return'.
+ `(progn ',form nil) nil 'compile-only)))
(defmacro ignore-errors (&rest body)
"Execute BODY; if an error occurs, return nil.