Subject: Re: Bug#66912: With `require', the byte compiler reports the wrong file for errors.

From: Alan Mackenzie <[email-masked]>
Date: Tue, 12 Nov 2024 14:53:56 +0000

Hello, Stefan.

On Sun, Nov 10, 2024 at 16:37:26 -0500, Stefan Monnier wrote:
> >> Because of my "A => B => compile => C => D" example: the message I want
> >> to have depends on the chain from the point where I catch the error
> >> (i.e. the `condition-case`) to the point where the error is signaled.
> >> And I don't really care about the debugger case.
> > That is no explanation as to WHY you think it's the right thing.
> > The point in that chain where we catch the error is an internal
> > implementation detail, of no interest to the user.

> Not at all.  In the above example, the error message goes to the
> compilation buffer, and it would be weird for that buffer to say "while
> loading A while loading B" whereas the compiled code loads neither.

OK, so you were using "the point in the chain where we catch the error",
which is of no interest to the user, as a proxy for how and where an
error message gets displayed.

I thought we were agreed that the "A => B => compile => C => D" was
vanishingly rare and probably doesn't occur at all in the Emacs sources.
In that case, why are you giving it priority over the other concerns
(such as consistency of messages displayed to the user) that I have
raised?

> > WHY are you so unconcerned about the debugger case?

> In the debugger case, I usually have direct access to the problematic
> code and usually don't care that much about the further parts of the
> context explaining why that code is executed.

But other users might like to see this information.  I certainly would.
The stack of files being loaded is likely to be of interest.  Even you
imply you would sometimes like to see it.

Would you please clarify whether you are opposed to outputting the
information (about the stack of files being loaded) in the debugger
case, or are merely indifferent about it.  If the former, I still don't
understand why; I would still appreciate justification.

> Occasionally I do, but "loading" is not special in this respect: I will
> just as often be interested to know which command was used, in which
> buffer, or which hook caused that code to be run.

It is true that Emacs error messages are typically poor in the extreme,
in that they fail to identify the pertinent command, buffer, hook, or
variable.  I have been trying to improve this for several years, with
mixed success.  The thing about loading is that it is frequently
recursive, typically by the function `require'.  Being told which file
the failing Lisp came from is as good as saying which buffer, and likely
better in batch mode.

> > I think it would be consistent to display "While loading..." the same
> > in both cases.

> To be honest, I don't see much value in displaying "while loading" in
> the echo area in general.

To be frank, displaying nothing but

    Wrong type argument: integer-or-marker-p, nil

to the user is insulting.  It is nearly content-free, giving the user no
clue as to where to start looking for the error.  It implies that the
users' time is less important than that of Emacs developers, who have
failed to implement proper error handling.

Informing the user which file the error occurred in, though far from
ideal, is significantly better than not doing so.

> I'm not opposed to it, but the only case where I know it could be
> helpful is during compilation (which I'm mostly interested to see it
> in the compilation buffer).

In this case, the error message is indeed displayed in *Compile-Log*.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).