Subject: bug#18968: 25.0.50; unhelpful "unused" warning from byte compiler

From: Stefan Monnier <[email-masked]>
Date: Wed, 05 Nov 2014 22:28:50 -0500

> Byte-compile this program:

> (defvar q-x)
> (defun z ()
>   (pop (aref q-x 0))
>   nil)

> I get:

> q.el:2:8:Warning: value returned from (aref v 0) is unused

> I think this warning is not very useful;

I'd tend to agree, tho it turned out it was useful because it pointed
out that (aref v 0) was called twice by the macro-expanded code instead
of only once.

So I installed the patch below which should fix the underlying problem.

        Stefan

=== modified file 'lisp/subr.el'
--- lisp/subr.el	2014-10-30 05:15:28 +0000
+++ lisp/subr.el	2014-11-06 03:25:36 +0000
@@ -169,7 +169,8 @@
          ;; So we can use `pop' in the bootstrap before `gv' can be used.
          (list 'prog1 place (list 'setq place (list 'cdr place)))
        (gv-letplace (getter setter) place
-         `(prog1 ,getter ,(funcall setter `(cdr ,getter)))))))
+         (macroexp-let2 macroexp-copyable-p x getter
+           `(prog1 ,x ,(funcall setter `(cdr ,x))))))))
 
 (defmacro when (cond &rest body)
   "If COND yields non-nil, do BODY, else return nil.