GNU bug report logs -
#31792
27.0.50; Regression in #'labels, recent versions
Previous Next
Reported by: Aidan Kehoe <kehoea <at> parhasard.net>
Date: Mon, 11 Jun 2018 23:12:01 UTC
Severity: normal
Tags: fixed, patch
Found in versions 27.0.50, 25.3
Fixed in version 26.2
Done: Noam Postavsky <npostavs <at> gmail.com>
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 31792 in the body.
You can then email your comments to 31792 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Mon, 11 Jun 2018 23:12:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Aidan Kehoe <kehoea <at> parhasard.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 11 Jun 2018 23:12:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
When I start this binary (see below for the details), do M-x byte-compile-file
/tmp/aidan/u.el RET, and then execute the following in *scratch*:
(progn (load "/tmp/aidan/u.elc")
(symbol-function 'my-package-accept-process-output))
I get:
=> my-package-accept-process-output-1
When I do the same in the emacs 22.1.1 that Apple built and shipped with
my OS, I get a compiled function object, as is much closer to being the
correct behaviour.
Contents of /tmp/aidan/u.el (a narrowed-down test case of some code I had
planned to write):
---- Begin:
(require 'cl)
(labels
((my-package-accept-process-output-1 (process-object &optional timeout-secs
timeout-msecs)
"Call `my-package-filter' and pass it the output of the last my-package
invocation."
(if (null process-object)
(error "No My-Package process to read output from!")
(let ((buf my-package-output-buffer)
my-package-output)
(if (not (bufferp buf))
(setq my-package-filter nil)
(with-current-buffer buf
(setq my-package-output (buffer-substring-no-properties
(point-min) (point-max))))
(my-package-filter t my-package-output)
(with-current-buffer buf
(erase-buffer)))))))
(defalias 'my-package-accept-process-output
(if (boundp 'my-package-async-processp)
#'accept-process-output
#'my-package-accept-process-output-1)))
---- End:
In GNU Emacs 27.0.50 (build 3, i386-apple-darwin10.8.0, NS appkit-1038.36 Version 10.6.8 (Build 10K549))
of 2018-06-11 built on bonbon
Repository revision: 94d60f59fc654706c3a52ed2c90c355b36be7898
Windowing system distributor 'Apple', version 10.3.1038
System Description: Mac OS X 10.6.8
Recent messages:
Auto-saving...done
Saving file /tmp/aidan/u.el...
Wrote /tmp/aidan/u.el
Compiling /tmp/aidan/u.el...
‘labels’ is an obsolete macro (as of 24.3); use ‘cl-labels’ instead.
Compiling /tmp/aidan/u.el...done
Wrote /tmp/aidan/u.elc
Loading /tmp/aidan/u.elc...done
Quit
Mark set [3 times]
Configured using:
'configure --with-wide-int CC=gcc-4.2
PKG_CONFIG_PATH=/usr/pkg/lib/pkgconfig:/X11/lib/pkgconfig'
Configured features:
RSVG IMAGEMAGICK DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
NS THREADS LCMS2
Important settings:
value of $LANG: de_DE.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny seq dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq cl-macs
disass cl-extra cl gv help-fns radix-tree help-mode easymenu cl-loaddefs
cl-lib warnings byte-opt compile comint ansi-color ring bytecomp
byte-compile cconv time-date elec-pair tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind kqueue cocoa ns lcms2 multi-tty make-network-process
emacs)
Memory information:
((conses 16 225419 15013)
(symbols 40 21102 1)
(miscs 36 68 413)
(strings 16 33618 3363)
(string-bytes 1 872171)
(vectors 12 37343)
(vector-slots 8 742671 16894)
(floats 8 49 351)
(intervals 36 910 74)
(buffers 860 18))
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Mon, 11 Jun 2018 23:32:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 31792 <at> debbugs.gnu.org (full text, mbox):
found 31792 25.3
quit
Aidan Kehoe <kehoea <at> parhasard.net> writes:
> When I do the same in the emacs 22.1.1 that Apple built and shipped with
> my OS, I get a compiled function object, as is much closer to being the
> correct behaviour.
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)
bug Marked as found in versions 25.3.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Mon, 11 Jun 2018 23:32:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Tue, 12 Jun 2018 22:59:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 31792 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
[0001-Fix-fun-handling-inside-labels-Bug-31792.patch (text/x-diff, inline)]
From aa197176d0de4a6b7d1ee5d16d0fc1750f7237cf Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
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
[Message part 3 (text/plain, inline)]
[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
Added tag(s) patch.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 12 Jun 2018 22:59:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Wed, 13 Jun 2018 13:17:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 31792 <at> debbugs.gnu.org (full text, mbox):
> 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)))
Looks good, but please add a comment before the call to macroexpand-all
reminding that lexical-let installs a macroexpander for `function` that
ends up calling cl--labels-convert.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Wed, 13 Jun 2018 16:58:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 31792 <at> debbugs.gnu.org (full text, mbox):
In article <mailman.1699.1528759928.1292.bug-gnu-emacs <at> gnu.org> you wrote:
> found 31792 25.3
> quit
> Aidan Kehoe <kehoea <at> parhasard.net> writes:
>> When I do the same in the emacs 22.1.1 that Apple built and shipped with
>> my OS, I get a compiled function object, as is much closer to being the
>> correct behaviour.
> 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)
Just as a matter of interest, the doc strings for both these functions
are poor.
That for cl-labels says "make temporary function bindings" without saying
what a "function binding" is (it's not obvious), without saying what
functions (?or symbols) are being bound, and doesn't say whether they get
bound one after the other (in `let*' fashion) or all at once (in `let'
fashion).
It goes on to say "The bindings can be recursive, ...". This is
gibberish to me.
Further, "the scoping is lexical". The scoping of what is lexical? And
in what?
I dare say I could fathom out most of these things with effort, but I
shouldn't have to. Maybe this macro could be of use to me, but with the
doc string as it is, I'll never find out. Pity.
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Wed, 13 Jun 2018 17:04:01 GMT)
Full text and
rfc822 format available.
Message #24 received at 31792 <at> debbugs.gnu.org (full text, mbox):
On 13 June 2018 at 12:57, Alan Mackenzie <acm <at> muc.de> wrote:
>> (labels ((foo () t))
>> #'foo) ;=> foo
>
>> (cl-labels ((foo () t))
>> #'foo) ;=> (lambda nil t)
>
> Just as a matter of interest, the doc strings for both these functions
> are poor.
Yes; the manual's descriptions are much better.
(cl) Function Bindings
https://www.gnu.org/software/emacs/manual/html_node/cl/Function-Bindings.html
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Thu, 14 Jun 2018 03:25:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 31792 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> Looks good, but please add a comment before the call to macroexpand-all
> reminding that lexical-let installs a macroexpander for `function` that
> ends up calling cl--labels-convert.
Ok, I extended the docstrings of cl-labels and cl-flet a bit and added a
test too.
[0001-Fix-fun-handling-inside-labels-Bug-31792.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Thu, 14 Jun 2018 03:33:01 GMT)
Full text and
rfc822 format available.
Message #30 received at 31792 <at> debbugs.gnu.org (full text, mbox):
> (defmacro cl-flet (bindings &rest body)
> "Make local function definitions.
> -Like `cl-labels' but the definitions are not recursive.
> +Bind the function cells of symbols within FORM.
I think this is wrong: it makes it sound like it does `fset`, which
is what CL's `flet` did, but not what `cl-flet` does.
If you look at the implementation, you'll see that it doesn't touch any
"function cell".
> +The bindings only take effect within FORM, not BODY, so you can't
> +write recursive function definitions. Use `cl-labels' for that.
> +See info node `(cl) Function Bindings' for details.
This is good, thanks.
> (defmacro cl-labels (bindings &rest body)
> - "Make temporary function bindings.
> -The bindings can be recursive and the scoping is lexical, but capturing them
> -in closures will only work if `lexical-binding' is in use.
> + "Make local function definitions.
> +Bind the function cells of symbols within FORM.
Same here about "function cells".
> diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
> index d53c8e0bbc..f6643158d2 100644
> --- a/lisp/emacs-lisp/cl.el
> +++ b/lisp/emacs-lisp/cl.el
> @@ -466,9 +466,12 @@ 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)))
> + ;; `lexical-let' adds `cl--function-convert' (which calls
> + ;; `cl--labels-convert') as a macroexpander for `function'.
> (macroexpand-all `(lexical-let ,vars (setq ,@sets) ,@body) newenv)))
Good, thanks.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Thu, 14 Jun 2018 04:15:01 GMT)
Full text and
rfc822 format available.
Message #33 received at 31792 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
>> +Bind the function cells of symbols within FORM.
>
> I think this is wrong: it makes it sound like it does `fset`, which
> is what CL's `flet` did, but not what `cl-flet` does.
> If you look at the implementation, you'll see that it doesn't touch any
> "function cell".
Hmm, the manual page says something similar:
-- Macro: cl-flet (bindings...) forms...
This form establishes `let'-style bindings on the function cells
of symbols rather than on the value cells.
It also wrongly claims that (quote FUNC) would work:
A "reference" to a function name is either a call to that
function, or a use of its name quoted by `quote' or `function' to
^^^^^^^
be passed on to, say, `mapcar'.
Perhaps both of those are leftovers from the original `flet'
description. How about this:
[v3-0001-Fix-fun-handling-inside-labels-Bug-31792.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Thu, 14 Jun 2018 18:06:02 GMT)
Full text and
rfc822 format available.
Message #36 received at 31792 <at> debbugs.gnu.org (full text, mbox):
>> I think this is wrong: it makes it sound like it does `fset`, which
>> is what CL's `flet` did, but not what `cl-flet` does.
>> If you look at the implementation, you'll see that it doesn't touch any
>> "function cell".
>
> Hmm, the manual page says something similar:
>
> -- Macro: cl-flet (bindings...) forms...
> This form establishes `let'-style bindings on the function cells
> of symbols rather than on the value cells.
>
> It also wrongly claims that (quote FUNC) would work:
>
> A "reference" to a function name is either a call to that
> function, or a use of its name quoted by `quote' or `function' to
> ^^^^^^^
> be passed on to, say, `mapcar'.
>
> Perhaps both of those are leftovers from the original `flet'
> description.
Sounds like it, yes.
> How about this:
Looks good to me, thank you,
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31792
; Package
emacs
.
(Wed, 20 Jun 2018 00:09:01 GMT)
Full text and
rfc822 format available.
Message #39 received at 31792 <at> debbugs.gnu.org (full text, mbox):
tags 31792 fixed
close 31792 26.2
quit
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> Looks good to me, thank you,
Pushed to emacs-26.
[1: e292c0973c]: 2018-06-19 20:02:16 -0400
Fix #'fun handling inside `labels' (Bug#31792)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e292c0973cf7a92819d312ea8a828b67e6adf1ab
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 20 Jun 2018 00:09:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.2, send any further explanations to
31792 <at> debbugs.gnu.org and Aidan Kehoe <kehoea <at> parhasard.net>
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 20 Jun 2018 00:09:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 18 Jul 2018 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 29 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.