GNU bug report logs - #36445
Byte-compilation does not warn about runtime use of variables defined only at compile time

Previous Next

Package: emacs;

Reported by: Wilfred Hughes <me <at> wilfred.me.uk>

Date: Sun, 30 Jun 2019 13:21:02 UTC

Severity: minor

Tags: confirmed

Full log


View this message in rfc822 format

From: Wilfred Hughes <me <at> wilfred.me.uk>
To: 36445 <at> debbugs.gnu.org
Subject: bug#36445: Byte-compilation does not warn about variables undefined at runtime
Date: Sun, 30 Jun 2019 14:20:16 +0100
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.