GNU bug report logs -
#36445
Byte-compilation does not warn about runtime use of variables defined only at compile time
Previous Next
Full log
View this message in rfc822 format
The byte-compiler warns about functions that are defined at
compile-time but not at runtime. However, it doesn't warn about
variables that are only defined at compile-time.
As a result, this program produces incorrect bytecode without any warnings:
(eval-when-compile
(defconst demo-one 1))
(defvar demo-some-var
`(foo bar ,demo-one))
Produces the following .elc file:
;ELC
;;; Compiled
;;; in Emacs version 26.1
;;; with all optimizations.
;;; This file uses dynamic docstrings, first added in Emacs 19.29.
;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar demo-some-var (list 'foo 'bar demo-one))
Could Emacs warn about variables in this situation, to match the logic
with functions?
Originally discussed in
https://emacs.stackexchange.com/questions/51075/how-do-i-get-byte-compilation-warnings-about-undefined-variables/51127
This bug report was last modified 5 years and 353 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.