unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar.
@ 2022-11-05 18:46 Alan Mackenzie
  2022-11-07 13:07 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 14+ messages in thread
From: Alan Mackenzie @ 2022-11-05 18:46 UTC (permalink / raw)
  To: 59057

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).





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-11-25 10:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05 18:46 bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar Alan Mackenzie
2022-11-07 13:07 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-07 20:20   ` Alan Mackenzie
2022-11-07 21:29     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-08 11:01       ` Alan Mackenzie
2022-11-08 14:12         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-07 21:31     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-09 13:40       ` Alan Mackenzie
2022-11-09 17:54         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-24 19:29           ` Stefan Kangas
2022-11-24 19:33             ` Eli Zaretskii
2022-11-24 20:36             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-24 21:12               ` Stefan Kangas
2022-11-25 10:36                 ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).