GNU bug report logs - #19704
25.0.50; funcall with hard-quote inside cl-labels uses the local function binding

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Tue, 27 Jan 2015 15:23:01 UTC

Severity: normal

Tags: patch

Found in versions 25.0.50, 25.0.94

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19704 in the body.
You can then email your comments to 19704 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#19704; Package emacs. (Tue, 27 Jan 2015 15:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 27 Jan 2015 15:23:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50;
 funcall with hard-quote inside cl-labels uses the local function
 binding
Date: Tue, 27 Jan 2015 17:22:36 +0200
In emacs-24 the below snippet returns (:global :local), whereas in master now, (:local :local).

(defun foo ()
  :global)

(cl-labels ((foo () :local))
  (list (funcall 'foo) (funcall #'foo)))

It's a bug, according to
http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00895.html.

In GNU Emacs 25.0.50.7 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
 of 2015-01-27 on axl
Repository revision: 11527553647f61798562f04c50b789edb8c15ac3
Windowing system distributor `The X.Org Foundation', version 11.0.11601901
System Description:	Ubuntu 14.10




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19704; Package emacs. (Fri, 10 Jun 2016 02:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 19704 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: 19704 <at> debbugs.gnu.org
Cc: Dmitry Gutov <dgutov <at> yandex.ru>
Subject: 25.0.50; funcall with hard-quote inside cl-labels uses the local
 function binding
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




Added tag(s) patch. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 10 Jun 2016 02:38:02 GMT) Full text and rfc822 format available.

bug Marked as found in versions 25.0.94. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 10 Jun 2016 02:38:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19704; Package emacs. (Fri, 10 Jun 2016 22:08:01 GMT) Full text and rfc822 format available.

Message #15 received at 19704 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>, 19704 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses
 the local function binding
Date: Sat, 11 Jun 2016 01:06:55 +0300
On 06/10/2016 05:37 AM, Noam Postavsky wrote:

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

Thanks, Noam. Seems to work fine here.

Stefan, how does it look to you?

Eli, can we have it in emacs-25 (it's a regression)?

> 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
>





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19704; Package emacs. (Sat, 11 Jun 2016 02:43:02 GMT) Full text and rfc822 format available.

Message #18 received at 19704 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 19704 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Noam Postavsky <npostavs <at> users.sourceforge.net>
Subject: Re: bug#19704: 25.0.50;
 funcall with hard-quote inside cl-labels uses the local function
 binding
Date: Fri, 10 Jun 2016 22:42:11 -0400
>> Seems that macroexp--expand-all got too aggressive, patch below
>> teaches it to back off in case of locally defined functions:
> Thanks, Noam. Seems to work fine here.
> Stefan, how does it look to you?

Looks OK, tho a bit on the hackish side.  Maybe a simpler solution is to
replace  (or 'quote 'function) with 'function (i.e. only apply the
optimization to (funcall #'foo ...) and not to (funcall 'foo ...)).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19704; Package emacs. (Sat, 11 Jun 2016 02:57:01 GMT) Full text and rfc822 format available.

Message #21 received at 19704 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 19704 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses
 the local function binding
Date: Fri, 10 Jun 2016 22:56:05 -0400
On Fri, Jun 10, 2016 at 10:42 PM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
> Looks OK, tho a bit on the hackish side.  Maybe a simpler solution is to
> replace  (or 'quote 'function) with 'function (i.e. only apply the
> optimization to (funcall #'foo ...) and not to (funcall 'foo ...)).

This works, and it matches the existing comment better too.




Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Sat, 11 Jun 2016 21:39:02 GMT) Full text and rfc822 format available.

Notification sent to Dmitry Gutov <dgutov <at> yandex.ru>:
bug acknowledged by developer. (Sat, 11 Jun 2016 21:39:02 GMT) Full text and rfc822 format available.

Message #26 received at 19704-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 19704-done <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#19704: 25.0.50;
 funcall with hard-quote inside cl-labels uses the local function
 binding
Date: Sat, 11 Jun 2016 17:38:34 -0400
>> Looks OK, tho a bit on the hackish side.  Maybe a simpler solution is to
>> replace  (or 'quote 'function) with 'function (i.e. only apply the
>> optimization to (funcall #'foo ...) and not to (funcall 'foo ...)).
> This works, and it matches the existing comment better too.

Thanks, installed,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 10 Jul 2016 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 37 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.