GNU bug report logs - #19613
25.0.50; cl-labels bug

Previous Next

Package: emacs;

Reported by: Katsumi Yamaoka <yamaoka <at> jpl.org>

Date: Fri, 16 Jan 2015 05:20:02 UTC

Severity: normal

Found in version 25.0.50

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 19613 in the body.
You can then email your comments to 19613 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#19613; Package emacs. (Fri, 16 Jan 2015 05:20:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 16 Jan 2015 05:20:03 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; cl-labels bug
Date: Fri, 16 Jan 2015 14:19:11 +0900
Hi,

This form got not to work recently:

(cl-labels ((fn (arg) arg))
  (apply #'fn (list "arg")))

It is because `fn' is not substituted with the one CL defines:

(let (--cl-fn--)
  (setq --cl-fn-- #'(lambda (arg) arg))
  (apply #'fn (list "arg")))

Thanks.

In GNU Emacs 25.0.50.1 (i686-pc-cygwin, GTK+ Version 3.10.9)
 of 2015-01-16 on localhost
Windowing system distributor `The Cygwin/X Project', version 11.0.11501000
Configured using:
 `configure --verbose --with-x-toolkit=gtk3'




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Fri, 16 Jan 2015 14:51:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Fri, 16 Jan 2015 09:50:03 -0500
> This form got not to work recently:

> (cl-labels ((fn (arg) arg))
>   (apply #'fn (list "arg")))

> It is because `fn' is not substituted with the one CL defines:

> (let (--cl-fn--)
>   (setq --cl-fn-- #'(lambda (arg) arg))
>   (apply #'fn (list "arg")))

I believe this was fixed yesterday, even before you filed the bug.
Could you double check?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Fri, 16 Jan 2015 20:10:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Katsumi Yamaoka <yamaoka <at> jpl.org>, 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Fri, 16 Jan 2015 15:09:28 -0500
Stefan Monnier wrote:

> I believe this was fixed yesterday, even before you filed the bug.
> Could you double check?

No, it still fails.




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Sat, 17 Jan 2015 03:58:01 GMT) Full text and rfc822 format available.

Notification sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
bug acknowledged by developer. (Sat, 17 Jan 2015 03:58:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 19613-done <at> debbugs.gnu.org, Katsumi Yamaoka <yamaoka <at> jpl.org>
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Fri, 16 Jan 2015 22:57:27 -0500
>> I believe this was fixed yesterday, even before you filed the bug.
>> Could you double check?
> No, it still fails.

I believe this time it is fixed,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Thu, 22 Jan 2015 07:08:02 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: 19613 <at> debbugs.gnu.org
Cc: monnier <at> iro.umontreal.ca
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Thu, 22 Jan 2015 16:07:17 +0900
On Fri, 16 Jan 2015 22:57:27 -0500, Stefan Monnier wrote:
> I believe this time it is fixed,

I have still a problem with `cl-labels' used within `lexical-let'.

(lexical-let (var)
  (cl-labels ((fn (arg) arg))
    (apply #'fn (list "arg"))))
 => apply: Symbol's function definition is void: fn

Emacs-w3m uses this kind of macros.  Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Mon, 26 Jan 2015 05:58:01 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Mon, 26 Jan 2015 14:57:49 +0900
[Message part 1 (text/plain, inline)]
On Thu, 22 Jan 2015 16:07:17 +0900, Katsumi Yamaoka wrote:
> I have still a problem with `cl-labels' used within `lexical-let'.

> (lexical-let (var)
>   (cl-labels ((fn (arg) arg))
>     (apply #'fn (list "arg"))))
>  => apply: Symbol's function definition is void: fn

When a `cl-labels' form is wrapped with `lexical-let', it runs
`cl--function-convert' instead of `cl--labels-convert'.
So, `cl--function-convert' also needs to be fixed like the ones
Stefan did in `cl--labels-convert'[1], doesn't it?  I tried the
attached patch and verified it fixes not only the `cl-labels'
bug but also the `cl-flet' bug[2].

[1] git diff -U 9d940c6 69f36af lisp/emacs-lisp/cl-macs.el
[2]
(lexical-let (var)
  (cl-flet ((fn (arg) arg))
    (apply #'fn (list "arg"))))
 => apply: Symbol's function definition is void: fn

[Message part 2 (text/x-patch, inline)]
--- cl.el~	2015-01-26 04:16:45.291325300 +0000
+++ cl.el	2015-01-26 05:53:38.810655900 +0000
@@ -374,10 +374,12 @@
           (setq cl--function-convert-cache (cons newf res))
           res))))
    (t
-    (let ((found (assq f macroexpand-all-environment)))
-      (if (and found (ignore-errors
-                       (eq (cadr (cl-caddr found)) 'cl-labels-args)))
-          (cadr (cl-caddr (cl-cadddr found)))
+    (let* ((found (assq f macroexpand-all-environment))
+           (replacement (and found
+                             (ignore-errors
+                               (funcall (cdr found) cl--labels-magic)))))
+      (if (and replacement (eq cl--labels-magic (car replacement)))
+          (nth 1 replacement)
         (let ((res `(function ,f)))
           (setq cl--function-convert-cache (cons f res))
           res))))))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Mon, 26 Jan 2015 15:15:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Mon, 26 Jan 2015 10:14:56 -0500
> -    (let ((found (assq f macroexpand-all-environment)))
> -      (if (and found (ignore-errors
> -                       (eq (cadr (cl-caddr found)) 'cl-labels-args)))
> -          (cadr (cl-caddr (cl-cadddr found)))
> +    (let* ((found (assq f macroexpand-all-environment))
> +           (replacement (and found
> +                             (ignore-errors
> +                               (funcall (cdr found) cl--labels-magic)))))
> +      (if (and replacement (eq cl--labels-magic (car replacement)))
> +          (nth 1 replacement)
>          (let ((res `(function ,f)))
>            (setq cl--function-convert-cache (cons f res))
>            res))))))

This looks correct.  Ideally this part of cl--function-convert should
delegate to cl--labels-convert to avoid the code duplication, tho.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Mon, 26 Jan 2015 23:02:02 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Tue, 27 Jan 2015 08:00:57 +0900
[Message part 1 (text/plain, inline)]
On Mon, 26 Jan 2015 10:14:56 -0500, Stefan Monnier wrote:
[...]
> This looks correct.  Ideally this part of cl--function-convert should
> delegate to cl--labels-convert to avoid the code duplication, tho.

That's much better.  Here it is:
[Message part 2 (text/x-patch, inline)]
--- cl.el~	2015-01-26 04:16:45.291325300 +0000
+++ cl.el	2015-01-26 22:57:02.040588600 +0000
@@ -342,6 +342,7 @@
 - renaming of F when it's a function defined via `cl-labels' or `labels'."
   (require 'cl-macs)
   (declare-function cl--expr-contains-any "cl-macs" (x y))
+  (declare-function cl--labels-convert "cl-macs" (f))
   (cond
    ;; ¡¡Big Ugly Hack!! We can't use a compiler-macro because those are checked
    ;; *after* handling `function', but we want to stop macroexpansion from
@@ -374,13 +375,8 @@
           (setq cl--function-convert-cache (cons newf res))
           res))))
    (t
-    (let ((found (assq f macroexpand-all-environment)))
-      (if (and found (ignore-errors
-                       (eq (cadr (cl-caddr found)) 'cl-labels-args)))
-          (cadr (cl-caddr (cl-cadddr found)))
-        (let ((res `(function ,f)))
-          (setq cl--function-convert-cache (cons f res))
-          res))))))
+    (setq cl--labels-convert-cache cl--function-convert-cache)
+    (cl--labels-convert f))))
 
 (defmacro lexical-let (bindings &rest body)
   "Like `let', but lexically scoped.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Mon, 26 Jan 2015 23:26:02 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Tue, 27 Jan 2015 08:25:49 +0900
On Tue, 27 Jan 2015 08:00:57 +0900, Katsumi Yamaoka wrote:
> --- cl.el~	2015-01-26 04:16:45.291325300 +0000
> +++ cl.el	2015-01-26 22:57:02.040588600 +0000
> @@ -342,6 +342,7 @@
>  - renaming of F when it's a function defined via `cl-labels' or `labels'."
>    (require 'cl-macs)
>    (declare-function cl--expr-contains-any "cl-macs" (x y))
> +  (declare-function cl--labels-convert "cl-macs" (f))

There needs to be:
  +  (defvar cl--labels-convert-cache)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Tue, 27 Jan 2015 02:07:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 19613 <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Mon, 26 Jan 2015 21:06:16 -0500
> That's much better.  Here it is:

Looks great, thanks,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19613; Package emacs. (Tue, 27 Jan 2015 03:17:02 GMT) Full text and rfc822 format available.

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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 19613-done <at> debbugs.gnu.org
Subject: Re: bug#19613: 25.0.50; cl-labels bug
Date: Tue, 27 Jan 2015 12:16:00 +0900
On Mon, 26 Jan 2015 21:06:16 -0500, Stefan Monnier wrote:
> Looks great, thanks,

Thanks.  Committed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 24 Feb 2015 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 115 days ago.

Previous Next


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