GNU bug report logs - #68509
30.0.50; pcase-dolist matches backquote pattern incorrectly

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Tue, 16 Jan 2024 15:06:01 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: Jim Porter <jporterbugs <at> gmail.com>, 68509 <at> debbugs.gnu.org
Subject: bug#68509: 30.0.50; pcase-dolist matches backquote pattern incorrectly
Date: Mon, 19 Feb 2024 21:41:43 -0500
Ihor Radchenko [2024-02-19 18:14:24] wrote:

> 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.

The doc for `pcase-let` is a bit more precise:

    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.

> In my patch, I proposed to skip such elements.
> An alternative could be throwing an error.

As I said, what you propose is a *different* construct.
Maybe we should add some extra option/keyword to `pcase-dolist` to
indicate what to do with elements that don't match (such as signaling
an error, a warning, silently skipping it, ...).

Similar issues affect `pcase-let`, of course.


        Stefan





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.