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

To reply to this bug, email your comments to 36445 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#36445; Package emacs. (Sun, 30 Jun 2019 13:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wilfred Hughes <me <at> wilfred.me.uk>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 30 Jun 2019 13:21:02 GMT) Full text and rfc822 format available.

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

From: Wilfred Hughes <me <at> wilfred.me.uk>
To: bug-gnu-emacs <at> gnu.org
Subject: 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




Changed bug title to 'Byte-compilation does not warn about runtime use of variables defined only at compile time' from 'Byte-compilation does not warn about variables undefined at runtime' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 04 Jul 2019 21:35:01 GMT) Full text and rfc822 format available.

Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 04 Jul 2019 21:35:01 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 04 Jul 2019 21:35:01 GMT) Full text and rfc822 format available.

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.