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

To reply to this bug, email your comments to 77557 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#77557; Package emacs. (Sat, 05 Apr 2025 18:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alan Mackenzie <acm <at> muc.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 05 Apr 2025 18:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: bug-gnu-emacs <at> gnu.org
Cc: Stefan Kangas <stefankangas <at> gmail.com>
Subject: master: macroexp--expand-all mismatches on (name (c-defun-name)).
Date: Sat, 5 Apr 2025 18:41:00 +0000
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


-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77557; Package emacs. (Sat, 05 Apr 2025 18:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 77557 <at> debbugs.gnu.org (full text, mbox):

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: Re: 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 70 days ago.

Previous Next


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