Subject: bug#46722: test-map-into fails

From: Stefan Monnier <[email-masked]>
Date: Wed, 05 Jan 2022 10:17:19 -0500

> You can't do,
>
> (funcall
>  (funcall
>   (backquote
>    (lambda (arg)
>      (lambda () arg)))
>   t))
>
> which is what `cl--generic-get-dispatcher` tries to do.

Is it?  Where does `cl--generic-get-dispatcher` do that?

Oh, you mean we don't guarantee that we use static scoping?
I think I see what mean.
Does the patch below help?

        Stefan

diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 983694204df..686a2375971 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -644,7 +644,8 @@ cl--generic-get-dispatcher
       ;; FIXME: For generic functions with a single method (or with 2 methods,
       ;; one of which always matches), using a tagcode + hash-table is
       ;; overkill: better just use a `cl-typep' test.
-      (byte-compile
+      (funcall
+       (lambda (exp) (let ((lexical-binding t)) (byte-compile exp)))
        `(lambda (generic dispatches-left methods)
           ;; FIXME: We should find a way to expand `with-memoize' once
           ;; and forall so we don't need `subr-x' when we get here.