Re: Compiler invalid reporting warning. An Emacs 30 compiler limitation/bug?

Michael Heerdegen via Users list for the GNU Emacs text editor <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Pierre Rouleau <[email protected]> writes:

> Hi all,
>
> Emacs 30.2.50 reports an unused lexical variable warning
> for code where the variable is used inside a cl-letf macro.
> [...]
>     (let ((kill-ring nil)
>           (captured-message nil))  ; <<<--- WARNING: Unused lexical
> variable ‘captured-message’
>       (cl-letf (((symbol-function 'message)
>                  (lambda (fmt &rest args)
>                    (setq captured-message ; <<<---- but it's used here!
>                          (apply #'format fmt args)))))
>         (pel-elcode-print-properties-of-sexp-at-point))
>       (should (equal (car kill-ring)
>                      "(declare (pure t) (side-effect-free error-free))")))))

Your variable is initialized and then its binding is changed, but the
value is indeed never used.  The warning is correct, these parts of the
code will not have any effect.


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.