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

From: Alan Mackenzie <[email-masked]>
Date: Wed, 6 Nov 2024 16:23:53 +0000

Hello, Stefan.

I've implemented your suggestion, and it mostly works.  Let me know if
you'd like to see the patch (for which I'd have to tidy up the source
code).  But ....

On Tue, Nov 05, 2024 at 18:20:03 -0500, Stefan Monnier wrote:
> > There needs to be some mechanism for resetting this variable to Qnil,
> > should the error handler fail to access it.

> I was thinking we wouldn't bother, just like the we don't bother
> emptying the match-data after we used it.

I'm getting problems when debug-on-error is non-nil, and a *Backtrace*
is on the screen.  At this stage, Vloads_in_progress is still non-nil.
So when another error occurs, even a trivial one like "next-line: End of
buffer", its error message gets prefixed by the "While loading ..."
strings.

This is a Bad Thing.  Do you have any suggestions for a fix?  Things
like artificially setting or binding Vloads_in_progress to nil don't
seem like proper fixes.

> > Also, we need to be careful about condition-cases in debuggers, where an
> > error, even if handled, might overwrite Vloads_in_progress_of_last_error.

> Yes, we may want to locally let-bind the var to preserve it, similarly
> to the occasional use of `save-match-data`.

I don't think this is a problem any more.  I only set
Vloads_in_progress_at_error (as I've renamed it as) when there's an
actual error, not the handling of a condition-case thing, or the like.

> > However, signal_or_quit is supposed to be a general low-level function,
> > and it doesn't seem ideal to bloat it out with special purpose tests.

> Indeed, which is also why I was pointing out that the thing could be
> generalized to other context information, so we don't get fixated on `load`.

That wasn't quite the sense I meant it in.  ;-)

> > Another possible problem with this wild idea is that debuggers, or parts
> > of them, might need to be autoloaded.  This shouldn't be a problem with
> > edebug.el, where the file would be loaded to be able to instrument a
> > form, but I don't think anything's loading debug.el before it gets used.

> If the let-binding that preserves the new var is performed around the
> call to the debugger (rather than being performed inside the debugger
> itself), we should be OK.

> > I think your idea might be better than my current patch, but I doubt
> > it's going to be much simpler.

I've tried it, and the above problem seems definitely to make it less
simple than the approach I originally took (which currently works).

Maybe we should go back to my original working approach.

> The thing I like is that it should be a better replacement for
> `Vsignaling_function` (which is currently a very low-tech feature which
> works only half the time).

OK, I haven't looked at that.

> >> > I think I would agree, but this would be difficult for .el[cn] files.
> >> > How about giving the line number just for .el files, something like:
> >> That's what I meant, yes.
> > OK, I'll think about that, but after we've got the basics (see above)
> > sorted out for this bug.

> Yes, there's no hurry.

Indeed not.  The bug has just passed its 1-year anniversary.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).