Subject: bug#53227: master: Wrong error message with M-: (funcall).

From: Alan Mackenzie <[email-masked]>
Date: Thu, 13 Jan 2022 18:24:30 +0000

Hello, Lars.

On Thu, Jan 13, 2022 at 10:32:44 +0100, Lars Ingebrigtsen wrote:
> Robert Pluim <[email-masked]> writes:

> > Itʼs not Ffuncall's responsibility to check that, itʼs 'eval' that
> > should be doing it. Compare with eg M-: (format), which correctly
> > signals 'wrong-number-of-arguments.

> Or rather macroexpand-all:

> (macroexpand-all '(format))
> => (format)

> (macroexpand-all '(funcall))
> => (funcall nil)

Yes, it is the macro expansion causing the problem, thanks.

The following fixes it (or, at least, "fixes" it; I'm not clear exactly
what the pcase--dontcare clause is there for).

diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 663856a8fb..eb5af9ece6 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -441,8 +373,9 @@ macroexp--expand-all
                              (macroexp--all-forms args)
                              form)
 	   (macroexp--expand-all newform))))
-
-      (`(funcall . ,(or `(,exp . ,args) pcase--dontcare))
+      (`(funcall)
+       form)
+      (`(funcall . (,exp . ,args))
        (let ((eexp (macroexp--expand-all exp))
              (eargs (macroexp--all-forms args)))
          ;; Rewrite (funcall #'foo bar) to (foo bar), in case `foo'

> Perhaps Stefan has some insights into this; added to the CCs.

> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

-- 
Alan Mackenzie (Nuremberg, Germany).