GNU bug report logs - #77557
master: macroexp--expand-all mismatches on (name (c-defun-name)).

Previous Next

Package: emacs;

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

Date: Sat, 5 Apr 2025 18:42:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Ship Mints <shipmints <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 77557 <at> debbugs.gnu.org, Stefan Kangas <stefankangas <at> gmail.com>
Subject: bug#77557: master: macroexp--expand-all mismatches on (name (c-defun-name)).
Date: Sat, 5 Apr 2025 14:50:45 -0400
[Message part 1 (text/plain, inline)]
On Sat, Apr 5, 2025 at 2:42 PM Alan Mackenzie <acm <at> muc.de> wrote:

> Hello, Emacs.
>
> In my .emacs I have the following:
>
> (eval-after-load "cc-mode"
>   '(progn
>      (if (not (fboundp 'c-display-defun-name))
>          (defun c-display-defun-name (&optional arg)
>            "Display the name of the current CC mode defun and the position
> in it.
> With a prefix arg, push the name onto the kill ring too."
>            (interactive "P")
>            (save-restriction
>              (widen)
>              (c-save-buffer-state ((name (c-defun-name))   <============
>                                    (limits (c-declaration-limits t))
>                                    (point-bol (c-point 'bol)))
>                (when name
>                  (message "%s.  Line %s/%s." name
>                           (1+ (count-lines (car limits) point-bol))
>                           (count-lines (car limits) (cdr limits)))
>                  (if arg (kill-new name))
>                  (sit-for 3 t))))))
>      (define-key c-mode-base-map "\C-cn" 'c-display-defun-name)
>      (put 'c-display-defun-name 'isearch-scroll t)))
>
> ..  While attempting to start my Emacs, the current Emacs master errors
> out with this form, giving the message:
>
>  stop  Warning (initialization): An error occurred while loading
> ‘/home/acm/.emacs’:
>
> error: Eager macro-expansion failure: (wrong-type-argument symbolp (name
> (c-defun-name))).
>
> ########################################################################
>
> The cause of the error is in macroexp--expand-all in the pcase subform
> near the end:  (`(,func . ,_) ....).  This subform triggers on (name
> (c-defun-name)) and calls (function-get '(name (c-defun-name))),
> thinking that ,func is a symbol.
>
> This bug became visible after this commit:
>
> commit a4ec9ca12969018cdf15b8cc713b3ba054326f99
> Author: Stefan Kangas <stefankangas <at> gmail.com>
> Date:   Tue Apr 1 21:25:33 2025 +0200
>
>     function-put: signal error with non-symbol
>
> ..  Before that commit function-get returned nil for a non-symbol
> argument.
>
> #########################################################################
>
> The following patch fixes the bug:
>
>
> diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
> index 64ec634620a..8fd596ef58c 100644
> --- a/lisp/emacs-lisp/macroexp.el
> +++ b/lisp/emacs-lisp/macroexp.el
> @@ -489,7 +489,7 @@ macroexp--expand-all
>                    (macroexp--unfold-lambda `(,fn ,eexp . ,eargs)))
>                   (_ `(,fn ,eexp . ,eargs)))))
>              (`(funcall . ,_) form)      ;bug#53227
> -            (`(,func . ,_)
> +            (`(,(and func (pred symbolp)) . ,_)
>               (let ((handler (function-get func 'compiler-macro)))
>                 ;; Macro expand compiler macros.  This cannot be delayed to
>                 ;; byte-optimize-form because the output of the
> compiler-macro can
>

Looks like this bug reported today
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77550
[Message part 2 (text/html, inline)]

This bug report was last modified 71 days ago.

Previous Next


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