unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28107: 26.0.50; Byte compilation shows an unused var warning for an used variable
@ 2017-08-16  6:11 Tino Calancha
  2017-08-17 16:39 ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Tino Calancha @ 2017-08-16  6:11 UTC (permalink / raw)
  To: 28107


Write a file '/tmp/test.el' with following content:
--8<-----------------------------cut here---------------start------------->8---
;; -*- lexical-binding: t; -*-

;; Compiles OK
(defun test ()
  (let ((lst (list "foo" 1)))
    (when (cdr lst)
      (equal (cdr lst) 1))))

;; Compiles OK
(defun getval (x) (cdr x))
(defun test3 ()
  (let ((alist (list (cons "foo" 1) (cons "bar" 2))))
    (dolist (x alist)
      (when (getval x)
        (equal (getval x) (alist-get (car x) alist))))))

;; 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))))))

--8<-----------------------------cut here---------------end--------------->8---

emacs -Q
M-x byte-compile-file /tmp/test.el RET
I got a warning from test2 func:
Warning: value returned from (cdr x) is unused

But the value is used as the `when' condition, and as `equal'
1st argument.


In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-08-16
Repository revision: 3305dec5387021791eb09a93df5ab784b2297dc8






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-12 15:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-16  6:11 bug#28107: 26.0.50; Byte compilation shows an unused var warning for an used variable Tino Calancha
2017-08-17 16:39 ` Glenn Morris
2017-08-17 16:45   ` Glenn Morris
2017-08-17 17:32   ` Tino Calancha
2017-08-18  1:42     ` Glenn Morris
2019-06-12 15:03       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).