From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: acm@muc.de, 66912@debbugs.gnu.org
Subject: bug#66912: With `require', the byte compiler reports the wrong file for errors.
Date: Sun, 12 Nov 2023 16:30:06 +0000 [thread overview]
Message-ID: <ZVD9jhW_i23vbPTe@ACM> (raw)
In-Reply-To: <jwvv8aiq1vp.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
On Fri, Nov 03, 2023 at 12:09:03 -0400, Stefan Monnier wrote:
> > The pertinent error information is discarded by one of two
> > condition-cases in the macro displaying-byte-compile-warnings in
> > emacs-lisp/bytecomp.el.
> Kind of, yes. But the info available there is hard to use: basically at
> that point we could get the error message and the backtrace, which is
> what we get when we set `byte-compile-debug`. In the case where
> `byte-compile-debug` is not set, we don't really want to display
> a backtrace, ....
Why not? We're not in the compilation any more, we're loading a file.
Some error has prevented that file loading, so we want a backtrace just
as we would get with M-x load-file foo.elc RET.
> .... so we'd have to "analyze" that backtrace to try and extract a
> useful error message from it, which is hard&brittle.
Indeed, so.
> > If these condition-case's are disabled (for example by spiking the
> > enclosing `if' forms)
> By "spiking" do you mean setting `byte-compile-debug`?
I actually commented out byte-compile-debug, replacing it with t. But
same idea, yes.
> > This appears to be a fundamental problem with condition-case. When an
> > error occurs, the stack gets unwound before the error handlers have a
> > chance to analyse it.
> [ This is going a bit on a tangent, but I think it would be good to add
> some support for something like Common-Lisp's `handler-bind`,
> i.e. error handlers that are run before unwinding the stack (so they
> can capture the stack trace as well as the value of dynbound vars at
> the moment the error occurs, for example).
> It would make it possible for ERT to refrain from activating
> `debug-on-error`, for example (which it does in order to capture the
> backtrace at the time of the error). ]
That sounds kind of useful.
> I think for this specific problem being discussed (which is indeed
> a fairly common occurrence in my experience), the better solution is to
> change `load` so it adds the "context" (i.e. filename and ideally also
> the approximate file position info) to errors.
> [ This may require something like `handler-bind`. ]
Another solution would be to dispense with
display-byte-compile-warnings, just letting compiler errors generate
backtraces.
The problem here is that there is no distinction in bytecomp.el between
"external" errors (such as from require) and errors detected by the
compiler in the source file being compiled. The first decidedly want a
backtrace, the second probably not. All these errors are handled as
though they were "internal" errors detected by the compiler. This is
suboptimal.
Perhaps we should report the second type of error (detected by the
compiler) by calling a warning function, as we do for warnings, and
removing the damaging condition-case's as suggested two paragraphs back.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2023-11-12 16:30 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 11:32 bug#66912: With `require', the byte compiler reports the wrong file for errors Alan Mackenzie
2023-11-03 16:09 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-12 16:30 ` Alan Mackenzie [this message]
2023-11-12 17:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-12 20:41 ` Alan Mackenzie
2023-11-12 21:19 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-12 23:00 ` Drew Adams
2024-10-29 18:59 ` Alan Mackenzie
2024-10-30 19:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-30 21:52 ` Alan Mackenzie
2024-10-30 22:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-02 13:47 ` Alan Mackenzie
2024-11-02 14:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-03 22:34 ` Alan Mackenzie
2024-11-04 2:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-04 12:52 ` Alan Mackenzie
2024-11-04 16:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-04 21:08 ` Alan Mackenzie
2024-11-05 3:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-05 4:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-05 14:54 ` Alan Mackenzie
2024-11-05 19:00 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-05 20:33 ` Alan Mackenzie
2024-11-05 23:20 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-06 16:23 ` Alan Mackenzie
2024-11-06 18:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-06 20:12 ` Alan Mackenzie
2024-11-06 23:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-07 12:37 ` Alan Mackenzie
2024-11-07 16:09 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-07 17:15 ` Alan Mackenzie
2024-11-08 13:42 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-08 20:01 ` Alan Mackenzie
2024-11-08 20:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 12:35 ` Alan Mackenzie
2024-11-09 16:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-10 10:40 ` Alan Mackenzie
2024-11-10 16:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-10 17:48 ` Alan Mackenzie
2024-11-10 21:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-12 14:53 ` Alan Mackenzie
2024-11-12 15:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-07 15:04 ` Alan Mackenzie
2024-11-05 12:18 ` Eli Zaretskii
2024-11-05 14:04 ` Alan Mackenzie
2024-11-05 14:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-04 16:35 ` Alan Mackenzie
2024-11-04 12:20 ` Eli Zaretskii
2024-11-04 13:13 ` Alan Mackenzie
2024-11-04 13:34 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZVD9jhW_i23vbPTe@ACM \
--to=acm@muc.de \
--cc=66912@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.