GNU bug report logs -
#68509
30.0.50; pcase-dolist matches backquote pattern incorrectly
Previous Next
Full log
Message #26 received at 68509 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> * lisp/emacs-lisp/pcase.el (pcase-dolist): Use `pcase' rather than
>> `pcase-let*' to match the list elements. Update the docstring,
>
> That changes its behavior. It *will* break code.
> This is basically not the same macro any more. Instead of being a macro
> that iterates over all the elements of the list, it becomes a macro
> which iterates only over the matching elements.
Currently, the docstring states:
PATTERN should be a `pcase' pattern describing the structure of
LIST elements, and LIST is a list of objects that match PATTERN,
i.e. have a structure that is compatible with PATTERN.
It is undefined what happens when LIST objects do not match PATTERN.
So, any code relying upon iterating over non-matching elements is
relying upon undefined, undocumented behaviour.
Moreover, current implementation binds /partially matching/ list
elements, which is even more fragile. From `pcase-let' docstring:
a mismatch may signal an error or may go
undetected, binding variables to arbitrary values, such as nil.
What I suggest is to change what happens when PATTERN does not much more
explicitly.
In my patch, I proposed to skip such elements.
An alternative could be throwing an error.
--
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.