GNU bug report logs - #28107
26.0.50; Byte compilation shows an unused var warning for an used variable

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Wed, 16 Aug 2017 06:13:02 UTC

Severity: minor

Tags: notabug

Found in version 26.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50;
 Byte compilation shows an unused var warning for an used variable
Date: Wed, 16 Aug 2017 15:11:47 +0900
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





This bug report was last modified 5 years and 350 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.