Subject: Re: bug#45056: 28.0.50; lexical-let doesn't work with returned closures on nativecomp

From: Andrea Corallo <[email-masked]>
Date: Sat, 05 Dec 2020 19:49:57 +0000

"Mark A. Hershberger" via "Bug reports for GNU Emacs, the Swiss army
knife of text editors" <[email-masked]> writes:

> I have a function (mah/firestarter-sentinel) that is called from
> make-process.  The make-process call looks like this:
>
>     (make-process :name "rsync"
>                           :buffer rsync-buff
>                           :stderr rsync-buff
>                           :command (apply 'list "rsync" args)
>                           :sentinel (mah/firestarter-sentinel (getenv "REMOTE_HOST") post-cmd))
>
> mah/firestarter-sentinal creates a lambda function and uses lexical-let
> to make its parameters (host and post-cmd) available to the lambda
> function that it returns to act as a sentinal.
>
> Using eval-last-sexp on mah/firestarter-sentinal works, but loading the
> function from a compiled file does not and results in the message:
>
>     mah/firestarter-sentinel: Symbol’s function definition is void: host
>
> Here is the function:
>
> (defun mah/firestarter-sentinel (host post-cmd)
>   "Sentinel function that will run the POST-CMD on HOST."
>   (lexical-let ((post-cmd post-cmd)
>                      (host host)
>                      (rsync-buff (get-buffer-create mah/rsync-buff-name)))
>     (lambda (proc event-type)
>       (message (concat "post cmd: " post-cmd "\nevent: " event-type))
>       (cond ((string-equal event-type "finished\n")
>                 (if post-cmd
>                     (progn (message (concat "rsync finished, running "
>                                             post-cmd))
>                         (mah/firestarter-do-post host post-cmd rsync-buff))
>                   (message "rsync finshed")))
>           (t (if post-cmd
>                  (progn (message (concat "rsync didn't finish normally, "
>                                          "running anyway.  Check "
>                                          mah/rsync-buff-name))
>                      (mah/firestarter-do-post host post-cmd rsync-buff))
>                  (message "rsync finshed with errors")))))))

Hi Mark,

have you checked if this behavior is common to the non native build?

  Andrea