bug#81493: 30.2; Incorrect byte-compiler warning about unused value

Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
"Drew Adams" <[email protected]> writes:

> I get this byte-compiler warning, which is incorrect, AFAICT: 
>
>   value from call to 'format' is unused

Reproducer:

#+begin_src emacs-lisp
(defun drew-test ()
  (when (format "%d" 5)
    (message "%s" (format "%d" 5))))
#+end_src

Your macro (not function, macro: `diredp-mark-if') call expands to
something similar.  I haven't checked the details but I guess that the
warning is intentional (the return value of `format' is always non-nil
so the actual return value is really not used).  I would rather fix the
macro and move the `when' test out of the expansion.

Note the compiler generates warnings for the expanded code - and above
the warning is (only) about the first `format' call.  You can interpret
it as a warning about a partially poorly written macro.


Michael.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.