Subject: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding

From: Noam Postavsky <[email-masked]>
Date: Thu, 9 Jun 2016 22:37:37 -0400

tag 19704 + patch
found 19704 25.0.94
quit

Seems that macroexp--expand-all got too aggressive, patch below
teaches it to back off in case of locally defined functions:

diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index ed4d6e4..ce5d5dc 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -261,9 +261,14 @@ macroexp--expand-all
         (format "%s quoted with ' rather than with #'"
                 (list 'lambda (nth 1 f) '...))
         (macroexp--expand-all `(,fun ,arg1 ,f . ,args))))
-      (`(funcall (,(or 'quote 'function) ,(and f (pred symbolp)) . ,_) . ,args)
-       ;; Rewrite (funcall #'foo bar) to (foo bar), in case `foo'
-       ;; has a compiler-macro.
+      ;; Rewrite (funcall #'foo bar) to (foo bar), in case `foo'
+      ;; has a compiler-macro.
+      (`(funcall (,(or 'quote 'function)
+                  ,(and f (pred symbolp)
+                        ;; Unless `foo' is a locally bound macro.
+                        (guard (not (assq f macroexpand-all-environment))))
+                  . ,_)
+                 . ,args)
        (macroexp--expand-all `(,f . ,args)))
       (`(,func . ,_)
        ;; Macro expand compiler macros.  This cannot be delayed to