Subject: bug#12299: 24.1; no byte compiler warning for inline function call with too few arguments [PATCH]

From: Stefan Monnier <[email-masked]>
Date: Fri, 23 Jul 2021 11:02:37 -0400

> diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
> index 341643c7d1..ad9f827171 100644
> --- a/lisp/emacs-lisp/byte-opt.el
> +++ b/lisp/emacs-lisp/byte-opt.el
> @@ -274,6 +274,7 @@ byte-compile-inline-expand
>        ((pred byte-code-function-p)
>         ;; (message "Inlining byte-code for %S!" name)
>         ;; The byte-code will be really inlined in byte-compile-unfold-bcf.
> +       (byte-compile--check-arity-bytecode form fn)
>         `(,fn ,@(cdr form)))

Hmm... wouldn't we want the warning to be emitted if the source code was itself
of the form constructed by `(,fn ,@(cdr form))?
IOW I think we want that `byte-compile--check-arity-bytecode` call to be
elsewhere (in the code that actually compiles the code constructed by
`(,fn ,@(cdr form))).

Also, as a general rule I think we should try and refrain from emitting
warnings from the code in byte-opt.el (warnings should be independent
from optimizations).

> -         `(,(symbol-function name) ,@(cdr form))))
> +         (let ((bc (symbol-function name)))
> +           (byte-compile--check-arity-bytecode form bc)
> +           `(,bc ,@(cdr form)))))

I think the same holds here.

        Stefan