GNU bug report logs -
#68509
30.0.50; pcase-dolist matches backquote pattern incorrectly
Previous Next
Full log
Message #11 received at 68509 <at> debbugs.gnu.org (full text, mbox):
Jim Porter <jporterbugs <at> gmail.com> writes:
> 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.
Not sure about pcase-let, but pcase-dolist specifically may be
simplified not to use pcase-let:
(if (pcase--trivial-upat-p (car spec))
`(dolist ,spec ,@body)
(let ((tmpvar (gensym "x")))
`(dolist (,tmpvar ,@(cdr spec))
(pcase ,tmpvar (,(car spec) ,@body)))))
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
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.