Subject: bug#64642: closed (Re: bug#64642: 29.0.92; Native compiler doesn't compile dynamically bound functions.)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 19 Jul 2023 11:32:02 +0000

Your bug report

#64642: 29.0.92; Native compiler doesn't compile dynamically bound functions.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
64642: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64642
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#64642: 29.0.92; Native compiler doesn't compile dynamically bound functions.
From: Alan Mackenzie <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked], Andrea Corallo <[email-masked]>, [email-masked]
Date: Wed, 19 Jul 2023 11:31:14 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Eli.

On Mon, Jul 17, 2023 at 19:06:58 +0300, Eli Zaretskii wrote:
> > From: Andrea Corallo <[email-masked]>
> > Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> > Date: Mon, 17 Jul 2023 09:42:31 -0400

> > >> It is unlikely that this will be fixed in Emacs 29, unless the fix is
> > >> so simple that will surprise me.

> > > Here is a fix.  Its simplicity probably doesn't surprise you (Eli), but
> > > the change is entirely within one function, and a lot of the patch is
> > > just whitespace changes.

> > > There are no problems running make bootstrap or make check with patch in
> > > place.  It also solves the bug; unless there are good reasons dynamically
> > > bound functions weren't handled.  Andrea?

> > Hi Alan,

> > the fix LGTM thanks for the patch, I think we only need to add a test as
> > well to exercise this code, something like the "free-fun" test in
> > comp-tests.el.

> Alan, when the patch is ready, please install on master.

DONE.  I'm closing the bug with this post.

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).

Subject: 29.0.92; Native compiler doesn't compile dynamically bound functions.
From: Alan Mackenzie <[email-masked]>
To: [email-masked]
Date: Sat, 15 Jul 2023 09:38:13 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Emacs.

In the Emacs 29 pretest version (or the master version):
(i) emacs -Q
(ii) C-x b foo.el <RET>
(iii) M-x emacs-lisp-mode <RET>
Don't set lexical-binding in this buffer.
(iv) Enter a function called foo:
    (defun foo () "foo doc string"
      (lambda (bar) "lambda doc string" (car bar)))
(v) With point after the function, evaluate it with C-x C-e.

(vi) M-: (native-compile 'foo)
This signals an error, native-compiler-error-dyn-func.  This is a bug.

#########################################################################

The immediate cause of the bug is in the version of
comp-spill-lap-function which processes named functions (comp.el).
Unlike the other version of the cl-defmethod (which processes lambda
functions), there is no code for dynamic functions here.

If the intention is not to process dynamic functions, this should be
indicated by an error message rather than a signal.  Personally, I feel
that dynamic functions ought to be handled in Emacs-29.

Fixing this bug should be relatively straightforward, since it should
only involve copying and adapting the corresponding code in the lambda
version of comp-spill-lap-function.

-- 
Alan Mackenzie (Nuremberg, Germany).