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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Ihor Radchenko <yantar92@HIDDEN>; dated Tue, 16 Jan 2024 15:06:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 68509 <at> debbugs.gnu.org:


Received: (at 68509) by debbugs.gnu.org; 19 Feb 2024 15:54:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 19 10:54:29 2024
Received: from localhost ([127.0.0.1]:43237 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rc5yP-00079e-7s
	for submit <at> debbugs.gnu.org; Mon, 19 Feb 2024 10:54:29 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35694)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rc5yN-00079M-OO
 for 68509 <at> debbugs.gnu.org; Mon, 19 Feb 2024 10:54:28 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 42DFA80841;
 Mon, 19 Feb 2024 10:54:01 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1708358040;
 bh=EL6SpcDxeOlFQBl9FxNTlWrjTYiWIL/WJLprmW+cpXM=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=QXzMu98DaYhlRzrLY1z+mIBYzcnMAPJeAAKADTXdBxvcgtgpWALPbwt9rsQZClcfj
 U+SE1v6IELnsZQhB+NoYOYDQYaf96xRcppKCefdb7modkubzGBEJIrCUsaw/vYWxVZ
 /ZkGLU77an7+CoijxA8e4s8hpBM0CqsptlM3EJKu+ZcjqizHXBifw9l+3j1v9tJso+
 /Zo8bUs1Oz7c2RkPGQUGnIbo15J8NeqM+Mbfz+W64u+Om+duzFEXBKhjqQf9nsK37Q
 W1l5rZykIxpaPbTOSDd0t4CIOsX5jVSPstQVlFiv3X5/EuLXzlt0BN2tepLPXbA53Q
 /uqweT9I6RimA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5A3EB8014F;
 Mon, 19 Feb 2024 10:54:00 -0500 (EST)
Received: from milanesa (unknown [23.233.149.155])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 38B5212008F;
 Mon, 19 Feb 2024 10:54:00 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
Subject: Re: bug#68509: 30.0.50; pcase-dolist matches backquote pattern
 incorrectly
In-Reply-To: <871q98hiqa.fsf@localhost> (Ihor Radchenko's message of "Mon, 19
 Feb 2024 10:05:33 +0000")
Message-ID: <jwvv86kv4cs.fsf-monnier+emacs@HIDDEN>
References: <87a5p5l3jm.fsf@localhost>
 <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
 <87sf2xjezi.fsf@localhost> <871q98hiqa.fsf@localhost>
Date: Mon, 19 Feb 2024 10:53:59 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.009 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 68509
Cc: Jim Porter <jporterbugs@HIDDEN>, 68509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

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


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.

Message received at 68509 <at> debbugs.gnu.org:


Received: (at 68509) by debbugs.gnu.org; 19 Feb 2024 15:52:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 19 10:52:17 2024
Received: from localhost ([127.0.0.1]:43226 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rc5wH-00074J-86
	for submit <at> debbugs.gnu.org; Mon, 19 Feb 2024 10:52:17 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21646)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rc5wE-00073y-Jk
 for 68509 <at> debbugs.gnu.org; Mon, 19 Feb 2024 10:52:16 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5C85080841;
 Mon, 19 Feb 2024 10:51:47 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1708357906;
 bh=HnwDE3qOsqFUF6iDe7RSQV628u7qjsYVDE6m+yh/gII=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=nRdDw3lRv2qVGfxEONaSnuYV9rbLuBm3GRxWZZFvQJoRqsvh76vmm1xRW3P1J/2XR
 raUUrSaTSHXmqqQeAXAUSQMYsG83i4EiPjcpZfBNRyJ0ZnvWMSBtbSN0P3iu++P1Ex
 Y9LAmh0rluLKwNrwLN1rCg6+r4Q666O4jYD7L82ZOdT/eMeHCsIPD8942qCdc66NQO
 z1ynQ3uC1kgUuj+ZC5IVRxEINIuOIfpqgA5WzkVIBfgkNCYeGa6bwAt6Fwo2IaPAxy
 sQOrevskJU6+5K3YHiiZLjwmm89rIgXRQElOuFCztVOJxww7516jXStJWP1s/cskYd
 /Pu97eQ8LwUdQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 522548014F;
 Mon, 19 Feb 2024 10:51:46 -0500 (EST)
Received: from milanesa (unknown [23.233.149.155])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2976E12012E;
 Mon, 19 Feb 2024 10:51:46 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Jim Porter <jporterbugs@HIDDEN>
Subject: Re: bug#68509: 30.0.50; pcase-dolist matches backquote pattern
 incorrectly
In-Reply-To: <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN> (Jim Porter's
 message of "Tue, 16 Jan 2024 08:52:27 -0800")
Message-ID: <jwv1q98wjss.fsf-monnier+emacs@HIDDEN>
References: <87a5p5l3jm.fsf@localhost>
 <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
Date: Mon, 19 Feb 2024 10:51:45 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.009 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 68509
Cc: Ihor Radchenko <yantar92@HIDDEN>, 68509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

>> 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
>> =E2=9B=94 Warning (emacs): "TODO" :: nil
>> =E2=9B=94 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':

Indeed, I consider the above a pilot error.
`pcase-dolist` and `pcase-let` use Pcase patterns to do *destructuring*,
which is a different task than the one done by `pcase` (which decides
whether a value matches a pattern or not).

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

I'm quite happy with the way it works when you use it as intended.
But I'm not really satisfied either with the way it behaves when the
coder doesn't understand its semantics, nor about the way we document
that semantics.

The difficulty in resolving this can be illustrated with the following
pattern:

    `(a . ,b)

This pattern leads to two tests: (consp VAL) and (eq 'a (car VAL)).
When destructuring, we want to throw away both tests (we want to throw
away most tests, except those needed to choose between two `or`
branches).

We could decide to emit a warning because we silently skip
the `eq` test, which would help the coders understand that the pattern
doesn't do what they think.
But emitting that same warning because we silently skip the `consp` test
would be really annoying because rewriting the pattern to avoid this
is impractical.

For a human, it's pretty easy to distinguish those two cases.  But it's
difficult to provide a precise definition that distinguishes those two case=
s.

We could also keep the tests and emit a warning or even an error when
they fail, but if that's the behavior you want, then you should
arguably use `pcase(-exhaustive)` instead.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.

Message received at 68509 <at> debbugs.gnu.org:


Received: (at 68509) by debbugs.gnu.org; 19 Feb 2024 12:59:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 19 07:59:47 2024
Received: from localhost ([127.0.0.1]:40670 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rc3FJ-0004l7-Lu
	for submit <at> debbugs.gnu.org; Mon, 19 Feb 2024 07:59:47 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34838)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rc3FF-0004kp-PK
 for 68509 <at> debbugs.gnu.org; Mon, 19 Feb 2024 07:59:43 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rc3En-0000vE-Lu; Mon, 19 Feb 2024 07:59:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=jXb2dk+P5wQjbr4buLF9jvXCOtDyChHe7bOMcRThoq0=; b=nFd3HF3A3B6p
 RWWIvDru4pCcE6+PLM2Fqpxhm5w1h7LfnQzPslGkEEqE41Pc9MA6DFy9r0TIYeDPDhIbHX2e8FejK
 KUCBqN7xbAPzh/QFH4IkLt+Cg3o6ACESOArg24zlkOPArtA/k/NyiWo+Iuc5uJudTpTGaZB2SVz67
 EfaVLubtUXmN7XiLQxbLsu0XX1fQ2EjhKzd9z9y9DLPgjsSYy9wZHZ5zcWVcemSwdV5ncalfamaVN
 +rr+8Y9Ynvk+DH2rBYZmwW5qROxEG4X89ZSa5ctr/nYmAZ6eDhzrIwuFt7BLVTNsnPj8lQodkGvrc
 1NhmylvfLgd9NuTXAA4/0w==;
Date: Mon, 19 Feb 2024 14:59:09 +0200
Message-Id: <86sf1opq3m.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <871q98hiqa.fsf@localhost> (message from Ihor Radchenko on Mon,
 19 Feb 2024 10:05:33 +0000)
Subject: Re: bug#68509: 30.0.50;
 pcase-dolist matches backquote pattern incorrectly
References: <87a5p5l3jm.fsf@localhost>
 <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
 <87sf2xjezi.fsf@localhost> <871q98hiqa.fsf@localhost>
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 68509
Cc: jporterbugs@HIDDEN, 68509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

> Cc: 68509 <at> debbugs.gnu.org
> From: Ihor Radchenko <yantar92@HIDDEN>
> Date: Mon, 19 Feb 2024 10:05:33 +0000
> 
> Ihor Radchenko <yantar92@HIDDEN> writes:
> 
> > 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)))))
> 
> See the attached patch.
> If the patch is acceptable, we also need to update the manual.

Thanks.  Adding Stefan to the discussion.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.

Message received at 68509 <at> debbugs.gnu.org:


Received: (at 68509) by debbugs.gnu.org; 19 Feb 2024 10:02:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 19 05:02:21 2024
Received: from localhost ([127.0.0.1]:40392 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rc0Td-0002XB-3e
	for submit <at> debbugs.gnu.org; Mon, 19 Feb 2024 05:02:21 -0500
Received: from mout01.posteo.de ([185.67.36.65]:45437)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rc0TZ-0002Ww-Lz
 for 68509 <at> debbugs.gnu.org; Mon, 19 Feb 2024 05:02:19 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 5DFFF24002B
 for <68509 <at> debbugs.gnu.org>; Mon, 19 Feb 2024 11:01:50 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1708336910; bh=6dO1eGIdqETlXJiX0pKaqJk+AGWPlQ1gJdOeKJhtq1M=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:
 From;
 b=h+RQAKsm+hOwqFdn+IEk2d4GtGCHfiGfxq6fav050waGtKkdemSgXnsLikH6iIoQ2
 vWKh8NmaIvApjTRYtG65mGzFvmVYo2aaif7n6TxeH39MsUpM3zkY3enyLyumDzT5b/
 8W3/n7wEclu25E+lXxgDbeZARWc3GJ4+sqviNTNNR0Minrg/CXMMwKWK0biH/8KG8Z
 CSOfZ5JfVYsetHojr2Jkxm0niaBzO01TxBkmvAHGqlCqWP0y5g1wfBnYT2z95Z2Hd4
 QRATS3RPV9sK+pI+dXOiPnxKSFujhRgXM7GdHdT4eds2LxUo2qVnP83Ry3RXHRXdhr
 vndRbPKf1mBoA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TddNs2MKVz6tvJ;
 Mon, 19 Feb 2024 11:01:49 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Jim Porter <jporterbugs@HIDDEN>
Subject: Re: bug#68509: 30.0.50; pcase-dolist matches backquote pattern
 incorrectly
In-Reply-To: <87sf2xjezi.fsf@localhost>
References: <87a5p5l3jm.fsf@localhost>
 <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
 <87sf2xjezi.fsf@localhost>
Date: Mon, 19 Feb 2024 10:05:33 +0000
Message-ID: <871q98hiqa.fsf@localhost>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 68509
Cc: 68509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

--=-=-=
Content-Type: text/plain

Ihor Radchenko <yantar92@HIDDEN> writes:

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

See the attached patch.
If the patch is acceptable, we also need to update the manual.

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-pcase-let-Skip-LIST-element-that-do-not-match-the-PA.patch

From f3e1362f7687c731e0ba4e410f005252309ffc3f Mon Sep 17 00:00:00 2001
Message-ID: <f3e1362f7687c731e0ba4e410f005252309ffc3f.1708337064.git.yantar92@HIDDEN>
From: Ihor Radchenko <yantar92@HIDDEN>
Date: Mon, 19 Feb 2024 13:02:21 +0300
Subject: [PATCH] pcase-let: Skip LIST element that do not match the PATTERN
 (bug#68509)

* lisp/emacs-lisp/pcase.el (pcase-dolist): Use `pcase' rather than
`pcase-let*' to match the list elements.  Update the docstring,
describing the behavior when list elements to not match the pattern.
The previous undefined behavior is removed.
* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-pcase-dolist): Add
new test.
---
 lisp/emacs-lisp/pcase.el            | 13 ++++++-------
 test/lisp/emacs-lisp/pcase-tests.el | 12 ++++++++++++
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index ae9bd87997c..8dc11b20a6f 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -329,21 +329,20 @@ pcase-let
 (defmacro pcase-dolist (spec &rest body)
   "Eval BODY once for each set of bindings defined by PATTERN and LIST elements.
 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.
+LIST elements, and LIST is a list of objects.
 For each element of LIST, this macro binds the variables in
 PATTERN to the corresponding subfields of the LIST element, and
-then evaluates BODY with these bindings in effect.  The
-destructuring bindings of variables in PATTERN to the subfields
-of the elements of LIST is performed as if by `pcase-let'.
+then evaluates BODY with these bindings in effect.  When an element does
+not match the pattern, such element is skipped.
+The destructuring bindings of variables in PATTERN to the subfields
+of the elements of LIST is performed as if by `pcase'.
 \n(fn (PATTERN LIST) BODY...)"
   (declare (indent 1) (debug ((pcase-PAT form) body)))
   (if (pcase--trivial-upat-p (car spec))
       `(dolist ,spec ,@body)
     (let ((tmpvar (gensym "x")))
       `(dolist (,tmpvar ,@(cdr spec))
-         (pcase-let* ((,(car spec) ,tmpvar))
-           ,@body)))))
+	 (pcase ,tmpvar (,(car spec) ,@body))))))
 
 ;;;###autoload
 (defmacro pcase-setq (pat val &rest args)
diff --git a/test/lisp/emacs-lisp/pcase-tests.el b/test/lisp/emacs-lisp/pcase-tests.el
index d062965952a..241729c108a 100644
--- a/test/lisp/emacs-lisp/pcase-tests.el
+++ b/test/lisp/emacs-lisp/pcase-tests.el
@@ -160,4 +160,16 @@ pcase-tests-setq
   (should-error (pcase-setq a)
                 :type '(wrong-number-of-arguments)))
 
+(ert-deftest pcase-tests-pcase-dolist ()
+  ;; Ignore non-matching elements.
+  (should
+   (equal
+    '(("DONE" . "a"))
+    (let (result)
+      (pcase-dolist (`(,(and (pred stringp) a) .
+		       ,(and (pred stringp) b))
+	             '(("TODO") ("DONE" . "a")))
+        (push (cons a b) result))
+      (nreverse result)))))
+
 ;;; pcase-tests.el ends here.
-- 
2.43.0


--=-=-=
Content-Type: text/plain


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

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.

Message received at 68509 <at> debbugs.gnu.org:


Received: (at 68509) by debbugs.gnu.org; 16 Jan 2024 18:40:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 16 13:40:39 2024
Received: from localhost ([127.0.0.1]:49754 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rPoMZ-0008JN-4C
	for submit <at> debbugs.gnu.org; Tue, 16 Jan 2024 13:40:39 -0500
Received: from mout02.posteo.de ([185.67.36.66]:39205)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rPoMW-0008J2-T2
 for 68509 <at> debbugs.gnu.org; Tue, 16 Jan 2024 13:40:38 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 53E8D240101
 for <68509 <at> debbugs.gnu.org>; Tue, 16 Jan 2024 19:40:30 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705430430; bh=+9lWokKlWPa+YiK+QC93xKekPz+nvfuy1BIU4d4ygrU=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=aCjzSkrZA7icpOcSBolEVQLYjSnDsnIqdPS6D2c5CrotUkTnXJ/QLRhPOXx/is0Y5
 1gVweGH4zEVRQnafMRBTB6jCrvYvNHt/TTsxsCK/TeolzYFZxy/U96YMn4/CeeZeeT
 YmAfXGQdWgbwNm8dXDWzMc6qjpuQBnZ0B/tQbU7nyFuGGBjWToXCYRwtRXtUFGTW7j
 rV65odGwYOkw5n3GJoZ5ycjzS/v3KLy1JbCIVg6Us1P/w12+of9MPCnZXKxt0QojVS
 l9gH/qihf4F6QXezznbMijlosByQK2Xtit7TFdoSiDPZ4DEOP98OpKb+wlked0GL5l
 Unxw6Th/bdDgg==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TDyW14nmJz6trs;
 Tue, 16 Jan 2024 19:40:29 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Jim Porter <jporterbugs@HIDDEN>
Subject: Re: bug#68509: 30.0.50; pcase-dolist matches backquote pattern
 incorrectly
In-Reply-To: <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
References: <87a5p5l3jm.fsf@localhost>
 <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
Date: Tue, 16 Jan 2024 18:43:45 +0000
Message-ID: <87sf2xjezi.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68509
Cc: 68509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Jim Porter <jporterbugs@HIDDEN> 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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.

Message received at 68509 <at> debbugs.gnu.org:


Received: (at 68509) by debbugs.gnu.org; 16 Jan 2024 16:52:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 16 11:52:35 2024
Received: from localhost ([127.0.0.1]:49585 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rPmfz-0003ji-8N
	for submit <at> debbugs.gnu.org; Tue, 16 Jan 2024 11:52:35 -0500
Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:53372)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jporterbugs@HIDDEN>) id 1rPmfw-0003jV-P4
 for 68509 <at> debbugs.gnu.org; Tue, 16 Jan 2024 11:52:34 -0500
Received: by mail-pg1-x52d.google.com with SMTP id
 41be03b00d2f7-5cf1f4f6c3dso3084363a12.2
 for <68509 <at> debbugs.gnu.org>; Tue, 16 Jan 2024 08:52:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705423946; x=1706028746; darn=debbugs.gnu.org;
 h=content-transfer-encoding:in-reply-to:from:references:to
 :content-language:subject:mime-version:date:message-id:from:to:cc
 :subject:date:message-id:reply-to;
 bh=tdeggJvxVOodRM3G/51HdCQo32MbkdIydgR/x4W5xqM=;
 b=NhpM49FEPuRovLIh3imNcLsT7y99XgjYoEbWRze9UoxIL+b/HxzKIPPavQEHOHgv5W
 6vmvV8XDZSS9Z1tgEu14Uoxqz5oFxZeoGPcFTlXZPYdLc+e7qmgoHDN5rAkOjnqnxqRi
 SsW5PmUVfhYfe1cDG2LBozXwIyH8qX5JPr4+SQYBkpuUnnfGajZpH9Jw4w8sYoTH0JIM
 lu98y4JG+lpMi9z7pc552celjcAfNfahcGyDSYQI3eV01sUl/jJTUtS+aSrA7MiBtg3d
 7gFBorG03XkPQCHT5e+YhqR9lEFA9e41Jo9H17rq0bX9C1oZ2kOh+ARTalqiNafY0Rf+
 K4wA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705423946; x=1706028746;
 h=content-transfer-encoding:in-reply-to:from:references:to
 :content-language:subject:mime-version:date:message-id
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=tdeggJvxVOodRM3G/51HdCQo32MbkdIydgR/x4W5xqM=;
 b=nzEnwD+JP6XqFsptcuRXSA3o9T61OCsTai+PkWAMP6Dy46Sb7mmwkftpAMa1+B6Yuc
 JCK9OVUft8pLF+ug+Ig3dBC3H9+RYh8+sIobgPdsrUkfi0cNfR+J3uzyo2Ehr7bmVypb
 4udBLD2s/zun0HCXgFXZrcKOcfYFcaBM6p3V2uZ/wldd1GL0jwwrDkvAJ3s3lmmHzmDC
 Zo97J+Occ7Bm9KND1swBrNBFp9S3xMz0DIfuNSwzW99X1+nkqFVdGYFdkExLOhbJj3FK
 aIZqBnX6CGToSPwlHnPGopbDBQWhNYLtoJUPhF2rbNmAuLkooNUngsw6jbM60w6iHWhw
 y8jw==
X-Gm-Message-State: AOJu0YyoAi6mJ58zUiCx8T42yxryMG6dXuOE9hzd/baw2+hQVNJanxWt
 KKnh2bMC4lvX7mmD6YT1D1o=
X-Google-Smtp-Source: AGHT+IEJrJcOANPQMZVLWS/QwV6Xs29cxh4lPdPjEQUSeuGXJBLFLHb1Z70GCa2+Ev57mx2mMVrS/A==
X-Received: by 2002:a05:6a20:da9b:b0:199:d6c7:2e44 with SMTP id
 iy27-20020a056a20da9b00b00199d6c72e44mr3814749pzb.3.1705423946325; 
 Tue, 16 Jan 2024 08:52:26 -0800 (PST)
Received: from [192.168.1.2] (076-168-148-233.res.spectrum.com.
 [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id
 fh7-20020a056a00390700b006d9b2d86bcasm9558087pfb.46.2024.01.16.08.52.25
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 16 Jan 2024 08:52:25 -0800 (PST)
Message-ID: <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@HIDDEN>
Date: Tue, 16 Jan 2024 08:52:27 -0800
MIME-Version: 1.0
Subject: Re: bug#68509: 30.0.50; pcase-dolist matches backquote pattern
 incorrectly
Content-Language: en-US
To: Ihor Radchenko <yantar92@HIDDEN>, 68509 <at> debbugs.gnu.org
References: <87a5p5l3jm.fsf@localhost>
From: Jim Porter <jporterbugs@HIDDEN>
In-Reply-To: <87a5p5l3jm.fsf@localhost>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68509
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Jan 2024 15:05:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 16 10:05:02 2024
Received: from localhost ([127.0.0.1]:49433 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rPkzu-0007FE-10
	for submit <at> debbugs.gnu.org; Tue, 16 Jan 2024 10:05:02 -0500
Received: from lists.gnu.org ([2001:470:142::17]:59156)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rPkzs-0007Er-Di
 for submit <at> debbugs.gnu.org; Tue, 16 Jan 2024 10:05:01 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1rPkzm-0003yv-Hc
 for bug-gnu-emacs@HIDDEN; Tue, 16 Jan 2024 10:04:54 -0500
Received: from mout01.posteo.de ([185.67.36.65])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1rPkzh-0004Du-15
 for bug-gnu-emacs@HIDDEN; Tue, 16 Jan 2024 10:04:54 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id A9F3B240027
 for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jan 2024 16:04:44 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705417484; bh=rmbY0EM1yzxtlzXn9sixFv4fr2rVX2U2laBnhq0bnj0=;
 h=From:To:Subject:Date:Message-ID:MIME-Version:
 Content-Transfer-Encoding:From;
 b=J+O+GWsmfrsEh5evE3VZpymzA10jtHRZxLFdh+kT0z9mqk4G1/vhiQ86Z/by9sjJH
 tyYNTs5f+vxg+95uPjQsNpwAmTJIF3paq3deIlnTStNlgomxY3b4FH0QS2Vh5W+539
 Yz374liPWtwLnE5JnvZwxsNQy5EfdAPryFmi8EbSfPm/Pz6yj4VRODmIXTNlmQZ4zH
 hDH0Dm4TkQxoqa7brTB0uEwdw0aMluHFVsLIxpJ2//7oxV4Vkykzfy1dRrn5YSx99V
 RJrD+gOD9Dbk+O3C41tN4YeiWeD/QXOCEm+de+cfHtZ08GjnHl4W3L6Y5nMHJ2flu5
 lNf9E9mBu2Knw==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TDsk40dVSz6tvm
 for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jan 2024 16:04:43 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; pcase-dolist matches backquote pattern incorrectly
X-Debbugs-Cc: 
Date: Tue, 16 Jan 2024 15:07:57 +0000
Message-ID: <87a5p5l3jm.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@HIDDEN;
 helo=mout01.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi,

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

=E2=9B=94 Warning (emacs): "TODO" :: nil
=E2=9B=94 Warning (emacs): "DONE" :: "a"

even though ("TODO") does not match the pattern.

In contrast

(dolist (el '(("TODO") ("DONE" . "a")))
  (pcase el
    (`(,(and (pred stringp) a) .
       ,(and (pred stringp) b))
     (warn "%S :: %S" a b))))

correctly displays

=E2=9B=94 Warning (emacs): "DONE" :: "a"


In GNU Emacs 30.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version
 3.24.39, cairo version 1.18.0) of 2024-01-16 built on localhost
Repository revision: 5f73258753ee91c8648e0be55332f7dbaea9fa8b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101010
System Description: Gentoo Linux


--=20
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>




Acknowledgement sent to Ihor Radchenko <yantar92@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#68509; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 19 Feb 2024 16:00:03 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.