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

From: Mattias Engdegård <[email-masked]>
Date: Fri, 23 Jul 2021 17:52:41 +0200

23 juli 2021 kl. 17.02 skrev Stefan Monnier <[email-masked]>:

> Hmm... wouldn't we want the warning to be emitted if the source code was itself
> of the form constructed by `(,fn ,@(cdr form))?

You mean when FN is a bytecode object? Sure, we can do that too. (We currently report an error when there are too many arguments but not too few.) However, it doesn't replace the newly inserted checks, because:

> 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))).

Tried that first, but then we no longer have the function name so the user sees

 Warning: ‹bytecode gibberish› called with 1 argument but requires 2

> 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).

Agree in general but for non-inlined calls we do the arity checks in the codegen, after optimising, and that's too late for inlined calls. We could do it in cconv, but then (a) we may not know the signature or (b) the call could be in dead code.

But this is good to have in mind -- we have a growing list of things to deal with in a compiler reorganisation. There is a lot of history in this code.