[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar.
From: |
Alan Mackenzie |
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).
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar.,
Alan Mackenzie <=
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/07
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/07
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Alan Mackenzie, 2022/11/09
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/09
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Kangas, 2022/11/24
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Eli Zaretskii, 2022/11/24