Subject: edebug chokes on cl-macrolet in macro expansions

From: Daniel Colascione <[email-masked]>
Date: Thu, 06 Mar 2025 01:05:48 -0800

In the snippet below, edebug-instrumenting my-fn breaks, but
instrumenting the morally equivalent my-fn2 works.

;; -*- lexical-binding: t -*-

(cl-defmacro my-wrapper (&rest body)
  (declare  (debug (body)))
  `(cl-macrolet ((my-local-macro (x)
                  (declare (debug (sexp)))
                  (cl-check-type x symbol)
                  nil))
    ,@body))

;; edebug instrument this fails the check-type above my-local-macro
;; gets (edebug-after 0 2 thing) instead of thing.
(defun my-fn () (my-wrapper (my-local-macro thing)))

;; edebug instrument works fine
(defun my-fn2 ()
  (cl-macrolet ((my-local-macro (x)
                  (declare (debug (sexp)))
                  (cl-check-type x symbol)
                  nil))
    (my-local-macro thing)))