Subject: Re: bug#31792: 27.0.50; Regression in #'labels, recent versions

From: Noam Postavsky <[email-masked]>
Date: Tue, 12 Jun 2018 18:58:29 -0400

tags 31792 + patch
quit

> Seems to have regressed in Emacs 25, cl-labels still works correctly.
> Here's a smaller reproducer:
>
> (labels ((foo () t))
>   #'foo) ;=> foo
>
> (cl-labels ((foo () t))
>   #'foo) ;=> (lambda nil t)

It looks like `labels' missed the update in [1: 69f36afa11], here's a
patch to apply it.  It's not immediately clear to me if the requirement
to use a backquoted lambda vs closure is based on using lexical scoping
where the macro is defined or where it's used, so I left that as is.
Should be fine for emacs-26, I think.

>From aa197176d0de4a6b7d1ee5d16d0fc1750f7237cf Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Tue, 12 Jun 2018 18:41:46 -0400
Subject: [PATCH] Fix #'fun handling inside `labels' (Bug#31792)

* lisp/emacs-lisp/cl.el (labels): Apply the equivalent of the
cl-labels change from 2015-01-16 "* lisp/emacs-lisp/cl-macs.el: Fix
last change".
---
 lisp/emacs-lisp/cl.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index d53c8e0bbc..85deb8cb4f 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -466,8 +466,9 @@ labels
 	(push var sets)
 	(push (cons (car binding)
                     `(lambda (&rest cl-labels-args)
-                       (cl-list* 'funcall ',var
-                                 cl-labels-args)))
+                       (if (eq (car cl-labels-args) cl--labels-magic)
+                           (list cl--labels-magic ',var)
+                         (cl-list* 'funcall ',var cl-labels-args))))
               newenv)))
     (macroexpand-all `(lexical-let ,vars (setq ,@sets) ,@body) newenv)))
 
-- 
2.11.0

[1: 69f36afa11]: 2015-01-16 17:49:00 -0500
  * lisp/emacs-lisp/cl-macs.el: Fix last change.
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=69f36afa11c0b754c40f4fc57408ccd85428e2b0