From e96bb822e3b47552d8ebf369af6255f5f21ca780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Sat, 28 Feb 2026 14:24:35 +0100 Subject: [PATCH] Don't complain on compiler-macro arity mismatch * lisp/emacs-lisp/macroexp.el (macroexp--compiler-macro): Don't warn if calling the compiler-macro handler elicits an arity error. This helps in two ways: no messy wrong-number-of-arguments errors during macro-expansion, only the actual warnings emitted by the compiler, and compiler-macros no longer need to be written defensively to avoid such errors. --- lisp/emacs-lisp/macroexp.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index d9ca6f0b19a..6a16ebb0fd2 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -126,8 +126,14 @@ case return FORM unchanged." form (apply handler form (cdr form))) (error - (message "Warning: Optimization failure for %S: Handler: %S\n%S" - (car form) handler err) + ;; Don't complain if there's an arity error when calling the handler + ;; itself as that is likely the just wrong number of arguments + ;; passed to the function; let the compiler take care of it. + (unless (and (eq (car err) 'wrong-number-of-arguments) + (eq (indirect-function (nth 1 err)) + (indirect-function handler))) + (message "Warning: Optimization failure for %S: Handler: %S\n%S" + (car form) handler err)) form)))) (defun macroexp--funcall-if-compiled (_form)