Subject: Re: bug#74052: Master: edebug fails to instrument nested pcase guard form.
From: Alan Mackenzie <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: Dmitry Gutov <[email-masked]>, [email-masked], [email-masked]
Date: Mon, 28 Oct 2024 16:46:59 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Stefan.

On Mon, Oct 28, 2024 at 09:49:55 -0400, Stefan Monnier wrote:
> Hi Alan,

[ .... ]

> > +  ;; Note: PF is evaluated in FUN rather than in this function, so that
> > +  ;; it can use any dynamic bindings created there.

> Nitpick: PF is not "evaluated" but "called".

Nits are important.  :-)  I've corrected that.

[ .... ]

> > @@ -84,14 +84,17 @@ 'pcase-FUN
> >  (defun pcase--edebug-match-pat-args (head pf)
> >    ;; (cl-assert (null (cdr head)))
> >    (setq head (car head))
> > -  (or (alist-get head '((quote sexp)
> > -                        (or    &rest pcase-PAT)
> > -                        (and   &rest pcase-PAT)
> > -                        (guard form)
> > -                        (pred  &or ("not" pcase-FUN) pcase-FUN)
> > -                        (app   pcase-FUN pcase-PAT)))
> > +  (let ((specs
> > +         (alist-get head '((quote sexp)
> > +                           (or    &rest pcase-PAT)
> > +                           (and   &rest pcase-PAT)
> > +                           (guard form)
> > +                           (pred  &or ("not" pcase-FUN) pcase-FUN)
> > +                           (app   pcase-FUN pcase-PAT)))))
> > +    (if specs
> > +        (funcall pf specs)
> >        (let ((me (pcase--get-macroexpander head)))
> > -        (funcall pf (and me (symbolp me) (edebug-get-spec me))))))
> > +        (funcall pf (and me (symbolp me) (edebug-get-spec me)))))))

> +1 (tho I'd hoist the common `(funcall pf` out of the `if`).

Done that too, by a slight rearrangement of the code.

I've committed the (corrected) patch, and I'm closing the bug with this
post.

> And thanks!

And thank you too for such a quick reply!

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).