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

From: Alan Mackenzie <[email-masked]>
Date: Fri, 8 Nov 2024 20:01:54 +0000

Hello, Stefan.

On Fri, Nov 08, 2024 at 08:42:29 -0500, Stefan Monnier wrote:
> > Yes.  When the debugger handles the error, the binding stack hasn't been
> > unwound at all, so Vloads_in_progress and Vloads_in_progress_at_error are
> > EQ.  So the difference between them would be empty.

> I understand that, but I don't think it explains why you think it's
> a problem.  E.g. when you're in the debugger, you can see the stack
> trace which tells you we're loading A, so you don't need to be told
> "while loading A" in the error message.

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.  You're suggesting that's not really necessary.

There may be some way the message might be output by a handler-bind
handler before the stack gets unwound, but which doesn't end up with a
debugger backtrace.  I haven't really thought that through yet.

Even when the information is in a debugger backtrace, I think there
would be merit in outputting "While loading foo.el... " as part of the
error message.  In the backtrace, the succession of entries for Fload is
going to be dispersed and not all that easy to trace, but is likely to
be one of the first things the person debugging will want to see.

> >> > Something very similar, if not the same, was the original handling of
> >> > byte-compile-form-stack.
> >> Something only you worked with, AFAICT.  So it doesn't have the same
> >> "known issues" advantage for the rest of us.
> > Oh, come on, Stefan!

> I'm just describing the way I see it: I personally don't have a good
> intuition of how/when it could misbehave nor how to work around such
> cases, whereas I very much do for the approach I propose and AFAICT it's
> not just because I proposed it but it's because it follows
> a known pattern, so I expect the same will hold for other coders.

Experience with byte-compile-form-stack suggests it won't misbehave.
It's simplicity should make it easy to think through.

> Of course it wouldn't be the first time I'd be wrong.  Also, I didn't
> say I objected to your approach, I just have a different preference: you
> don't have to convince me.

In the approach where we copy Vloads_in_progress inside signal_or_quit,
we still don't have a reliable way of preventing the "While loading
foo.el... " from getting into other messages where it doesn't belong,
like "end of screen".  You've suggested taking the difference between
Vloads_in_progress at two stages of the error handling.  I'll admit I
haven't tried that out yet, but it feels to me complicated and fragile.

It feels we've lost momentum for this fix.  I still favour my current
version of the patch, which works, and I think is simpler than the
alternative approach.

It would be nice to get this finalised and committed.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).