Subject: bug#46834: 28.0.50; byte-compiling the standard counter closure fails

From: Stefan Monnier <[email-masked]>
Date: Mon, 01 Mar 2021 09:23:48 -0500

> diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
> index a2fe37a1ee586..7d00b453caf1c 100644
> --- a/lisp/emacs-lisp/bytecomp.el
> +++ b/lisp/emacs-lisp/bytecomp.el
> @@ -2785,16 +2785,12 @@ byte-compile--reify-function
>      (dolist (binding env)
>        (cond
>         ((consp binding)
> -        ;; We check shadowing by the args, so that the `let' can be moved
> -        ;; within the lambda, which can then be unfolded.  FIXME: Some of those
> -        ;; bindings might be unused in `body'.
> -        (unless (memq (car binding) args) ;Shadowed.
> -          (push `(,(car binding) ',(cdr binding)) renv)))
> +        (push `(,(car binding) ',(cdr binding)) renv))
>         ((eq binding t))
>         (t (push `(defvar ,binding) body))))
>      (if (null renv)
>          `(lambda ,args ,@preamble ,@body)
> -      `(lambda ,args ,@preamble (let ,(nreverse renv) ,@body)))))
> +      `(let ,renv (lambda ,args ,@preamble ,@body)))))

This looks good, thanks, but it changes the nature of the output of
`byte-compile` from a function value to an expression whose evaluation
returns a function value.  So I think we should tweak `byte-compile` so
it calls `eval` on the result in this particular case.

        Stefan