[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#28107: 26.0.50; Byte compilation shows an unused var warning for an
From: |
Tino Calancha |
Subject: |
bug#28107: 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
- bug#28107: 26.0.50; Byte compilation shows an unused var warning for an used variable,
Tino Calancha <=