Subject: Re: bug#70368: [PATCH] Use a dedicated type to represent interpreted-function values

From: Stefan Monnier <[email-masked]>
Date: Tue, 30 Apr 2024 09:51:49 -0400

Michael Heerdegen [2024-04-30 14:49:58] wrote:
> Stefan Monnier <[email-masked]> writes:
>> Could you post an actual recipe?
>> so AFAICT the old code would have burped on `apply` just as well.
>
> It's indeed a special case.  I'm doing this:
>
> #+begin_src emacs-lisp
> (advice-add 'edebug-enter :before
>   (lambda (&rest _) "Turn off `view-mode' which would shadow edebug bindings."
>     (when (fboundp 'view-mode)
>       (view-mode -1)))
>   '((name . turn-off-view-mode)))
> #+end_src
>
> Then hitting d in any Edebug recursive edit will pop up the
> mentioned warning.

And you're sure this did not occur before commit f2bccae22bd4?
In my test, the same warning appears in Emacs compiled just before
commit f2bccae22bd4.

> Maybe you know how to silently skip the frame in this case, too?

You can just silence the warning.  All it means is that your backtrace
will not be as clean as it "should".

The problem is raised inside the code that tries to display a backtrace
that pretends the code is not annotated.
More specifically, the annotated contains things like:

    (edebug-enter <BLABLA> (lambda () <REALCODE>))

so `edebug--strip-instrumentation` walks (down) the frames of the
backtrace, and when it sees `edebug-enter` it hides that frame but it
should also hide the frame for the (lambda () <REALCODE>) so as to
pretend that we jumped right into <REALCODE>.
Normally, those two frames follow each other right away, but your advice
makes it so that after `edebug-enter` you have a bunch of other frames
calling your advice and then calling the original code which finally
calls the (lambda () <REALCODE>) we want to strip.
Ideally, we'd want to strip all of that away, but it's somewhere between
difficult and impossible to do so reliably.  The code errs on the side
of leaving the backtrace less clean than it should rather than take the
risk of stripping away "real" code.

> Else I will find a way to silence the warning for myself in some
> unorthodox way.

I can see a few other options, but I suggest you open another bug report
for that (with a title like "view-mode should not shadow edebug bindings").

        Stefan