GNU bug report logs -
#68509
30.0.50; pcase-dolist matches backquote pattern incorrectly
Previous Next
Full log
Message #8 received at 68509 <at> debbugs.gnu.org (full text, mbox):
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.
This bug report was last modified 1 year and 112 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.