* bug#15326: 24.3; Incorrect "variable not left unused" in destructuring cl-loop
@ 2013-09-10 18:25 Christopher Wellons
2013-09-10 21:05 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Wellons @ 2013-09-10 18:25 UTC (permalink / raw)
To: 15326
The byte compiler emits an invalid warning about used "_" lexical
variables in cl-loop destructuring bindings. This was casually mentioned
in bug#8711, where destructuring-bind was fixed (presumably, since it's
fine now) but not loop.
Create a source file like so,
;;; -*- lexical-binding: t; -*-
(require 'cl-lib)
(cl-loop for (_ value) in '((a 1) (b 2))
collect value)
Then compile,
$ emacs -Q -batch -f batch-byte-compile tmp.el
In toplevel form:
tmp.el:3:1:Warning: variable `_' not left unused
Wrote /tmp/tmp.elc
In the macro expansion, the _ is declared in a `let', then later set
with `setq', "using" it.
In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.2)
of 2013-06-25 on sochi, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
System Description: Debian GNU/Linux unstable (sid)
Configured using:
`configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
'--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
'--with-x-toolkit=gtk3' '--with-toolkit-scroll-bars'
'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
'LDFLAGS=-Wl,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15326: 24.3; Incorrect "variable not left unused" in destructuring cl-loop
2013-09-10 18:25 bug#15326: 24.3; Incorrect "variable not left unused" in destructuring cl-loop Christopher Wellons
@ 2013-09-10 21:05 ` Stefan Monnier
2013-09-11 4:47 ` Christopher Wellons
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-09-10 21:05 UTC (permalink / raw)
To: Christopher Wellons; +Cc: 15326
> In the macro expansion, the _ is declared in a `let', then later set
> with `setq', "using" it.
A `setq' does not *use* a variable. It just sets it, affecting
later uses. If there's no later uses, the setq is just a no-op.
Fixing this will require someone to dig into the `cl-loop' macro.
Stefan "who suspects it's not really fixed in
destructuring-bind either"
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15326: 24.3; Incorrect "variable not left unused" in destructuring cl-loop
2013-09-10 21:05 ` Stefan Monnier
@ 2013-09-11 4:47 ` Christopher Wellons
2013-09-28 1:08 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Wellons @ 2013-09-11 4:47 UTC (permalink / raw)
To: 15326
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> A `setq' does not *use* a variable. It just sets it, affecting
> later uses.
I mean that the compiler counts the setq as a use even in this simple
expression:
(let (_)
(setq _ t))
;; Warning: variable `_' not left unused
> If there's no later uses, the setq is just a no-op.
Without bothering to dig into the bytecode for it, it seems that the
compiler is still emitting code for the setq:
(defun foo ()
(let (_)
(setq _ t)))
(defun bar ()
(let (_)))
(equal (byte-compile 'foo)
(byte-compile 'bar))
;; => nil
Maybe I'm not understanding what you mean by "no-op" here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15326: 24.3; Incorrect "variable not left unused" in destructuring cl-loop
2013-09-11 4:47 ` Christopher Wellons
@ 2013-09-28 1:08 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-09-28 1:08 UTC (permalink / raw)
To: Christopher Wellons; +Cc: 15326-done
I have just installed a patch into trunk which changes the code
generated by `cl-loop' such that this warning should not appear
any more.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-28 1:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10 18:25 bug#15326: 24.3; Incorrect "variable not left unused" in destructuring cl-loop Christopher Wellons
2013-09-10 21:05 ` Stefan Monnier
2013-09-11 4:47 ` Christopher Wellons
2013-09-28 1:08 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.