Subject: bug#67900: 30.0.50; Emacs Crahes When Executing Command `consult-buffer'

From: Chang Xiaoduan <[email-masked]>
Date: Mon, 08 Jan 2024 11:28:26 +0800

Hello Andrea,

After some further test, I have found that the crash is reproducible
when the declare form is absent from the function definition inside the
macro definition.

#+begin_src emacs-lisp
(defmacro consult--define-state (type)
  "Define state function for TYPE."
  (declare (speed 1))
  `(defun ,(intern (format "consult--%s-state" type)) ()
     ,(format "State function for %ss with preview.
The result can be passed as :state argument to `consult--read'." type)
     (declare (speed 1)) ;; If absent, crash is reproducible
     (consult--state-with-return (,(intern (format "consult--%s-preview" type)))
                                 #',(intern (format "consult--%s-action" type)))))
#+end_src

Even if I use `emacs-lisp-macroexpand' to expand all instances of this
macro, and add declare form to these functions, missing the declare form
in the function definition inside the macro definition still triggers
the crash. In fact, if the functions generated from the macro expansion
contains the declare form seems has nothing to do with the crash. Do you
have any idea why this is happening and how it may be fixed?

Thanks