GNU bug report logs - #59057
Emacs 29. Byte compiler sometimes forgets about a defvar.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Sat, 5 Nov 2022 18:47:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: 59057 <at> debbugs.gnu.org
Subject: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a defvar.
Date: Sat, 5 Nov 2022 18:46:49 +0000
Hello, Emacs.

With an up to date master version, start emacs -Q.

(i) Visit bug-compile-defvar.el, which looks like this:

#########################################################################
;; -*- lexical-binding: t -*-

(eval-and-compile
  (defun version-check ()
    (>= emacs-major-version 28)))

(defmacro acm-defvar (var)
  `(eval-when-compile
;     (when (version-check)
       (defvar ,var)
       (setq ,var emacs-major-version)
;       )
     ))

(acm-defvar l-s-p)

(eval-when-compile
  (message
   "\nl-s-p is %sin byte-compile-bound-variables"
   (if (memq 'l-s-p byte-compile-bound-variables)
       "" "not "))
  (message
   "l-s-p is %sbound"
   (if (boundp 'l-s-p) "" "not ")))

(defun acm-bind-l-s-p ()
 (let ((l-s-p emacs-major-version))
   (message "Nothing much\n")))
#########################################################################

The idea here is that the macro acm-defvar itself calls defvar, creating
a variable.

(ii) Do M-x byte-compile-file RET ~/bug-compile-defvar.el.
(iii) Note that this works properly, giving out the two messages, the
  first of which confirms that the new variable l-s-p has been entered
  into the list byte-compile-bound-variables.

(iv) Edit the buffer, removing both single semicolon comment markers, and
  save the file.
(v) Do M-x byte-compile-file RET ~/bug-compile-defvar.el again.
(vi) Note that now the new variable is NOT in
  byte-compile-bound-variables.  This is a bug.
(vii) Note also that there is a spurious compiler warning about l-s-p
  being an unused lexical variable in function acm-bind-l-s-p.  This is
  also a bug.

This bug doesn't occur on Emacs 28.  I have a feeling it was introduced
into Emacs 29 very recently.

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 2 years and 262 days ago.

Previous Next


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