GNU bug report logs - #12369
24.2.50; cl-loop: variable not left unused

Previous Next

Package: emacs;

Reported by: Christopher Schmidt <christopher <at> ch.ristopher.com>

Date: Thu, 6 Sep 2012 13:16:02 UTC

Severity: minor

Tags: confirmed

Found in version 24.2.50

To reply to this bug, email your comments to 12369 AT debbugs.gnu.org.

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#12369; Package emacs. (Thu, 06 Sep 2012 13:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Schmidt <christopher <at> ch.ristopher.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 06 Sep 2012 13:16:02 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2.50; cl-loop: variable not left unused
Date: Thu,  6 Sep 2012 14:06:05 +0100 (BST)
severity: minor

    ;; -*- lexical-binding: t -*-

    (require 'cl-lib)
    (cl-loop for (rms . emacs) in nil)

Byte compile this piece of code.

    Warning: Unused lexical variable `rms'

Attempting to fix this warning by renaming rms to _rms results in
another warning.

    Warning: variable `_rms' not left unused

GNU Emacs 24.2.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of
2012-09-06.

        Christopher




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12369; Package emacs. (Thu, 06 Sep 2012 15:44:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#12369: 24.2.50; cl-loop: variable not left unused
Date: Thu, 06 Sep 2012 11:43:04 -0400
>     ;; -*- lexical-binding: t -*-
>     (require 'cl-lib)
>     (cl-loop for (rms . emacs) in nil)
> Byte compile this piece of code.
>     Warning: Unused lexical variable `rms'

Yes, first bug: `emacs' is not listed as unused.

> Attempting to fix this warning by renaming rms to _rms results in
> another warning.
>     Warning: variable `_rms' not left unused

Yup, second bug.

This is all due to the code generated by cl-loop which was optimized to
use `set' in the loop instead of `let'.  This made sense for dynamically
scoped code where `let' is a bit slower, but for lexically-scoped code,
it's the exact opposite, so we should change the generated code from:

   (identity
    (catch '--cl-block-nil--
      (let* ((--cl-var-- nil)
             (emacs nil) (rms nil))
        (while (consp --cl-var--)
          (setq emacs (car --cl-var--) rms (pop emacs))
          (setq --cl-var-- (cdr --cl-var--)))
        nil)))
to
   (identity
    (catch '--cl-block-nil--
      (let* ((--cl-var-- nil))
        (while (consp --cl-var--)
          (let* ((tmp (car --cl-var--))
                 (emacs (car tmp))
                 (rms (cdr tmp)))
            (setq --cl-var-- (cdr --cl-var--))))
        nil)))


-- Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12369; Package emacs. (Tue, 01 Jun 2021 07:19:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 12369 <at> debbugs.gnu.org
Subject: Re: bug#12369: 24.2.50; cl-loop: variable not left unused
Date: Tue, 01 Jun 2021 09:18:29 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>     ;; -*- lexical-binding: t -*-
>>     (require 'cl-lib)
>>     (cl-loop for (rms . emacs) in nil)
>> Byte compile this piece of code.
>>     Warning: Unused lexical variable `rms'
>
> Yes, first bug: `emacs' is not listed as unused.

This problem is still present in Emacs 28.

>> Attempting to fix this warning by renaming rms to _rms results in
>> another warning.
>>     Warning: variable `_rms' not left unused
>
> Yup, second bug.

This one is fixed, though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 01 Jun 2021 07:19:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12369; Package emacs. (Sat, 05 Jun 2021 20:09:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 12369 <at> debbugs.gnu.org
Subject: Re: bug#12369: 24.2.50; cl-loop: variable not left unused
Date: Sat, 05 Jun 2021 16:08:40 -0400
>>>     ;; -*- lexical-binding: t -*-
>>>     (require 'cl-lib)
>>>     (cl-loop for (rms . emacs) in nil)
>>> Byte compile this piece of code.
>>>     Warning: Unused lexical variable `rms'
>> Yes, first bug: `emacs' is not listed as unused.
> This problem is still present in Emacs 28.

Indeed, because it *is* used internally by the code expanded from the
destructuring-bind.

>>> Attempting to fix this warning by renaming rms to _rms results in
>>> another warning.
>>>     Warning: variable `_rms' not left unused
>> Yup, second bug.
> This one is fixed, though.

Hmm... I wonder what caused this change.


        Stefan





This bug report was last modified 4 years and 7 days ago.

Previous Next


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