Subject: Re: bug#68509: 30.0.50; pcase-dolist matches backquote pattern incorrectly

From: Jim Porter <[email-masked]>
Date: Tue, 16 Jan 2024 08:52:27 -0800

On 1/16/2024 7:07 AM, Ihor Radchenko wrote:
> Consider the following
> 
> (pcase-dolist (`(,(and (pred stringp) a) .
> 		 ,(and (pred stringp) b))
> 	       '(("TODO") ("DONE" . "a")))
>    (warn "%S :: %S" a b))
> 
> Executing the above yields
> 
> ⛔ Warning (emacs): "TODO" :: nil
> ⛔ Warning (emacs): "DONE" :: "a"
> 
> even though ("TODO") does not match the pattern.

This isn't an issue with 'pcase-dolist', but rather a known/intentional 
limitation of 'pcase-let':

(pcase-let ((`(,(and (pred stringp) a) .
                ,(and (pred stringp) b))
              '("TODO")))
   (warn "%S :: %S" a b))
   -> Warning (emacs): "TODO" :: nil

The 'pcase-let' docstring says this:

> Each EXP should match (i.e. be of compatible structure) to its
> respective PATTERN; a mismatch may signal an error or may go
> undetected, binding variables to arbitrary values, such as nil.

I do think we should fix it somehow though. This behavior is extremely 
confusing, and as much as I'm a fan of 'pcase', I'm emphatically *not* a 
fan of how this part works.