Subject: bug#28107: 26.0.50; Byte compilation shows an unused var warning for an used variable

From: Tino Calancha <[email-masked]>
Date: Fri, 18 Aug 2017 02:32:59 +0900 (JST)

On Thu, 17 Aug 2017, Glenn Morris wrote:

> Tino Calancha wrote:
>
>> ;; Warning: value returned from (cdr x) is unused
>> (defun test2 ()
>>   (let ((alist (list (cons "foo" 1) (cons "bar" 2))))
>>     (dolist (x alist)
>>     (when (cdr x)
>>       (equal (cdr x) (alist-get (car x) alist))))))
>
> Isn't this function a no-op?
> Eg dolist does not return the last value from the body.
> So a smaller example of the same thing is:
>
> (dolist (x '(1))
>  (equal (+ x 2) 3))
>
> which returns nil.
Even without the dolist we get such warning:
$> cat /tmp/test.el
;; -*- lexical-binding: t; -*-
(let ((x 1))
   (and (equal (+ x 2) 3)))

M-x byte-compile-file RET /tmp/test RET
Compiling file /tmp/test.el at Fri Aug 18 02:30:59 2017
test.el:2:1:Warning: value returned from (+ x 2) is unused
test.el:2:1:Warning: value returned from (+ x 2) is unused

I used (+ x 2) as 1st argument for `equal'.  What more should i do to
use it? Maybe invite (+ x 2) to the cinema?
I hope (+ x 2) will pay, cinema it's too expensive here.