Subject: bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes

From: Michael Heerdegen <[email-masked]>
Date: Wed, 25 Apr 2018 02:11:38 +0200

Stefan Monnier <[email-masked]> writes:

> > -the return value (nil if RESULT is omitted).
> > +the return value (nil if RESULT is omitted).  Note that RESULT
> > +should not be used unless it makes use of VAR.
>
> I would drop the "unless it makes use of VAR".

Yes.

For example,

#+begin_src emacs-lisp
(let ((count 10) (result 0))
   (dotimes (i count result)
     (print i)
     (setq result (+ result i))))
#+end_src

produces the warning - but doesn't RESULT "make use of the VAR"?

With the suggested patch, we would have a strange macro argument, using
it can produce strange compiler warnings, and we would have an obscure
description how these should be avoided.  It has to stop.

Michael.