Subject: bug#79416: 31.0.50; current value of `macro-declarations-alist' not from definition in byte-run.el

From: David Ponce <[email-masked]>
Date: Tue, 9 Sep 2025 22:11:10 +0200

Hello,

I found that the value of the variable `macro-declarations-alist', as
defined in byte-run.el, is not the value used in emacs.  To illustrate,
start emacs -Q and evaluate macro-declarations-alist, the result is
something like:

'((cl-optimize cl--optimize)
  (gv-expander gv--expander-defun-declaration)
  (debug byte-run--set-debug)
  (autoload-macro byte-run--set-autoload-macro)
  (no-font-lock-keyword byte-run--set-no-font-lock-keyword)
  (advertised-calling-convention
   byte-run--set-advertised-calling-convention)
  (obsolete byte-run--set-obsolete)
  (interactive-only byte-run--set-interactive-only)
  (pure byte-run--set-pure
        "If non-nil, the compiler can replace calls with their return value.\nThis may shift errors from run-time to compile-time.")
  (side-effect-free byte-run--set-side-effect-free
		   "If non-nil, calls can be ignored if their value is unused.\nIf `error-free', drop calls even if `byte-compile-delete-errors' is nil.")
  (important-return-value byte-run--set-important-return-value
			 "If non-nil, warn about calls not using the returned value.")
  (compiler-macro byte-run--set-compiler-macro)
  (doc-string byte-run--set-doc-string) (indent byte-run--set-indent)
  (speed byte-run--set-speed) (safety byte-run--set-safety)
  (completion byte-run--set-completion) (modes byte-run--set-modes)
  (interactive-args byte-run--set-interactive-args)
  (ftype byte-run--set-function-type))

 From the definition in byte-run.el the value is:

((debug byte-run--set-debug)
  (autoload-macro byte-run--set-autoload-macro)
  (no-font-lock-keyword byte-run--set-no-font-lock-keyword)
  (cl-optimize cl--optimize) (gv-setter gv--setter-defun-declaration)
  (gv-expander gv--expander-defun-declaration)
  (advertised-calling-convention
   byte-run--set-advertised-calling-convention)
  (obsolete byte-run--set-obsolete)
  (interactive-only byte-run--set-interactive-only)
  (pure byte-run--set-pure
        "If non-nil, the compiler can replace calls with their return value.\nThis may shift errors from run-time to compile-time.")
  (side-effect-free byte-run--set-side-effect-free
		   "If non-nil, calls can be ignored if their value is unused.\nIf `error-free', drop calls even if `byte-compile-delete-errors' is nil.")
  (important-return-value byte-run--set-important-return-value
			 "If non-nil, warn about calls not using the returned value.")
  (compiler-macro byte-run--set-compiler-macro)
  (doc-string byte-run--set-doc-string) (indent byte-run--set-indent)
  (speed byte-run--set-speed) (safety byte-run--set-safety)
  (completion byte-run--set-completion) (modes byte-run--set-modes)
  (interactive-args byte-run--set-interactive-args)
  (ftype byte-run--set-function-type))

Compared to the version in byte-run.el, the current version is
missing the declaration: '(gv-setter gv--setter-defun-declaration)

This leads to this warning when byte-compiling or loading the attached
test file code.el, after starting emacs -Q: Warning: Unknown macro
property ‘gv-setter’.  And running the small test at the end of
code.el signal the error (void-function \(setf\ my--get-v\)).

If the value of `macro-declarations-alist' is then refreshed from the
definition in byte-run.el, the same file is byte-compiled without
warning, and the small test returns the expected result.

Maybe the issue is in gv.el that doesn't autoload the gv-setter
declaration for macros.  The attached V0 patch seems to have fixed the
problem for me.

Can you please confirm the issue and maybe fix it, if my patch is
correct?

Thanks

In GNU Emacs 31.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version
  3.24.49, cairo version 1.18.2) of 2025-09-08
Repository revision: 5be32aa047d18b578412e8b249bb4f128a0dc207
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101018
System Description: Fedora Linux 42 (KDE Plasma Desktop Edition)

Configured using:
  'configure --with-native-compilation=no
  --with-tree-sitter=no'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM XRANDR GTK3
ZLIB

Important settings:
   value of $LC_TIME: fr_FR.utf8
   value of $LANG: fr_FR.UTF-8
   locale-coding-system: utf-8-unix
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index b6c1f2c9f9f..1b39ddd5413 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -203,8 +203,9 @@ gv--setter-defun-declaration
       (push x defun-declarations-alist)))
 ;;;###autoload
 (or (assq 'gv-setter defun-declarations-alist)
-    (push (list 'gv-setter #'gv--setter-defun-declaration)
-	  defun-declarations-alist))
+    (let ((x (list 'gv-setter #'gv--setter-defun-declaration)))
+      (push x macro-declarations-alist)
+      (push x defun-declarations-alist)))
 
 ;;;###autoload
 (let ((spec (get 'compiler-macro 'edebug-declaration-spec)))