Subject: Re: bug#78872: Byte compiler: warning message lacks line and column numbers.

From: Stefan Monnier <[email-masked]>
Date: Mon, 30 Jun 2025 10:55:01 -0400

>> > By the time '(1 font-lock-keyword-place t) gets used by the
>> > byte-compile inside c-make-font-lock-search-function, that quote
>> > has been evaluated away.
>
>> Aaahhhh!
>
> The warning is correct, though.  That form needs to look like
>     '(1 'font-lock-keyword-place t)

+1 !

>> Actually, I think it happens here because the stack is empty in the
>> inner `byte-compile` (it would have to consult the stack of the outer
>> compiler, but the two compiler invocations don't know each other, so
>> it's not that simple).
> If I increase the depth limit of 10 to 14 or more, I get the position
> in the warning - just the wrong position.  ;-(  I'll need to look into
> this a bit more.

I think it's simply that contrary to my belief, `bytecomp.el` doesn't
empty the stack before it starts its work, so the "depth 14" reaches to
the part of the stack that belongs to the outer compilation.

In this case, it happens to be the right thing to do (the position is
not ideal but given that we stripped the sympos it's the best we have),
although in general I think this can lead to confusing location info
(e.g. if the compilation of file A happens to (auto)load file B which
calls `byte-compile` somewhere at top-level, warnings from B could be
misattributed to A).

> So perhaps the best thing to do is add a warning to the documentation
> of byte-compile not to use it inside eval-when/and-compile, but
> instead to prefer a macro.

Fine by me, tho according to `grep` this is not a common "mistake",
so I'm not sure it's worth the trouble.

        Stefan