Subject: workaround

From: Paul Pogonyshev <[email-masked]>
Date: Sun, 19 Mar 2017 20:31:58 +0100

Attached patch is a workaround for the bug. It adds special handling
of lambdas to `cl--sm-macroexpand', similar to the way it handles
`let'. However, there is an unhandled case of "binding" symbols to
forms. I'm also not sure what would be correct behavior in old
non-lexical-scope code (do we still care?).

So, this patch cannot really go in as-is, but it can serve as a base
for a real fix.
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 58bcdd52ac..52d946a0c0 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2092,6 +2092,21 @@ except that it additionally expands symbol macros."
                                 (car exp))
                              ,(nreverse nbs)
                              ,@body)))))
+            (`(function (lambda . ,(or `(,params . ,body) _dontcare)))
+             (let (found nbs)
+               (dolist (param params)
+                 (let* ((sm (assq param env)))
+                   (push (if (not (cdr sm))
+                             param
+                           (let ((nexp (cadr sm)))
+                             (setq found t)
+                             (unless (symbolp nexp) (error "FIXME"))
+                             nexp))
+                         nbs)))
+               (when found
+                 (setq exp `(function (lambda
+                                        ,(nreverse nbs)
+                                        ,@body))))))
             ;; FIXME: The behavior of CL made sense in a dynamically scoped
             ;; language, but for lexical scoping, Common-Lisp's behavior might
             ;; make more sense (and indeed, CL behaves like Common-Lisp w.r.t