* bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding
@ 2015-01-27 15:22 Dmitry Gutov
2016-06-10 2:37 ` Noam Postavsky
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2015-01-27 15:22 UTC (permalink / raw)
To: 19704
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding
2015-01-27 15:22 bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding Dmitry Gutov
@ 2016-06-10 2:37 ` Noam Postavsky
2016-06-10 22:06 ` Dmitry Gutov
0 siblings, 1 reply; 6+ messages in thread
From: Noam Postavsky @ 2016-06-10 2:37 UTC (permalink / raw)
To: 19704; +Cc: Dmitry Gutov
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding
2016-06-10 2:37 ` Noam Postavsky
@ 2016-06-10 22:06 ` Dmitry Gutov
2016-06-11 2:42 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2016-06-10 22:06 UTC (permalink / raw)
To: Noam Postavsky, 19704; +Cc: Stefan Monnier
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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding
2016-06-10 22:06 ` Dmitry Gutov
@ 2016-06-11 2:42 ` Stefan Monnier
2016-06-11 2:56 ` Noam Postavsky
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2016-06-11 2:42 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 19704, Noam Postavsky
>> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding
2016-06-11 2:42 ` Stefan Monnier
@ 2016-06-11 2:56 ` Noam Postavsky
2016-06-11 21:38 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Noam Postavsky @ 2016-06-11 2:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 19704, Dmitry Gutov
On Fri, Jun 10, 2016 at 10:42 PM, Stefan Monnier
<monnier@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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding
2016-06-11 2:56 ` Noam Postavsky
@ 2016-06-11 21:38 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2016-06-11 21:38 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 19704-done, Dmitry Gutov
>> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-11 21:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-27 15:22 bug#19704: 25.0.50; funcall with hard-quote inside cl-labels uses the local function binding Dmitry Gutov
2016-06-10 2:37 ` Noam Postavsky
2016-06-10 22:06 ` Dmitry Gutov
2016-06-11 2:42 ` Stefan Monnier
2016-06-11 2:56 ` Noam Postavsky
2016-06-11 21:38 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).