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

From: Alan Mackenzie <[email-masked]>
Date: Sun, 10 Nov 2024 10:40:31 +0000

Hello, Stefan.

On Sat, Nov 09, 2024 at 11:45:36 -0500, Stefan Monnier wrote:
> >> > OK, I see what you mean.  I took it for granted that the message should
> >> > be the same, regardless of whether it is reported by a debugger or by
> >> > the error handler.
> >> AFAIK the debugger does not emit the "error message" at all, it shows
> >> the error object instead, so it's already different.
> > That doesn't seem to address the point I made above at all.

> Then I don't know what "the message" you're referring to.
> (or are you referring to some other point you made elsewhere?)

I simply meant what the user sees on the screen.  If the user sees
"While loading foo.el... \nWrong type argument: listp, baz" whilst doing
something, then enables the debugger and repeats the action, she should
see the same message at the top of the backtrace.  Surely?  Truncating
that message can only lead to confusion.

> >> And the full info would readily be available from `Vloads_in_progress_at_error`.
> > Vloads_in_progress_at_error is not available to the user, being an
> > internal variable.

> [ I'd make it user-visible, as well Vload_in_progress, but that's not
>   actually relevant.  ]

> Even if it's not directly exposed to the user the info *is* available,
> so we can offer ways to make use of it.

I am proposing a single way.

> > The problem with the Vloads_in_progress_at_error approach is that its
> > information gets prefixed to EVERY error message which occurs while the
> > debugger's recursive edit is in progress.  This is not a Good Thing.

> If `load-in-progress-at-error` hold (C B A), I'd make the error message
> emit either nothing, or just C, or B and C, or A and B and C depending
> on where in the call stack we're calling from (using the `while` loop
> that compares to `load-in-progress`).

> >From within the debugger, presumably `load-in-progress` would still be
> (C B A), so error messages would usually display no "while loading" at
> all, unless the errors themselves occur within a load of some file D,
> of course.

> Note that this is not just the behavior we happen to get with the hacks
> I came upon along the way.  It's the behavior I'm aiming for (e.g. it's
> also the behavior that we'd get with the `handler-bind` approach
> I advocated earlier).

I'll go back and see if I can find that.

Again, why do you think this is what we should aim for, rather than
having the same message in the error handler and at the top of a
backtrace?

[ .... ]

> Sorry, I meant

>     (equal (prefix-load-file-names
>             (error-message-string ERROR-OBJECT))
>            (prefix-load-file-names
>             (error-message-string ERROR-OBJECT)))

OK, that would indeed return nil if the first call to p-l-f-names was
the first such call since the error occurred.

> [ I assumed you had added a call to `prefix-load-file-names` in
>   `error-message-string`.  Not sure why you didn't, but I haven't
>   thought very much about which option is best in this regard.  ]

I wasn't actually aware of the function error-message-string.  Seeing as
how it is called from many places (over 100), there doesn't seem to be
any advantage in putting a call to prefix-load-file-names inside it.

[ .... ]

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).