From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#68509: 30.0.50; pcase-dolist matches backquote pattern incorrectly Date: Fri, 23 Feb 2024 14:05:19 +0000 Message-ID: <87bk87i8dc.fsf@localhost> References: <87a5p5l3jm.fsf@localhost> <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@gmail.com> <87sf2xjezi.fsf@localhost> <871q98hiqa.fsf@localhost> <8734to8gov.fsf@localhost> <87o7cbz21n.fsf@localhost> <87jzmzyxlv.fsf@localhost> <87y1berrh6.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32659"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jim Porter , 68509@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 23 15:28:45 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdWXc-0008Js-Qk for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Feb 2024 15:28:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdWXI-0006tn-Pn; Fri, 23 Feb 2024 09:28:24 -0500 Original-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 ) id 1rdWOp-0002MA-Ml for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 09:19:39 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdWOp-0006QR-Ef for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 09:19:39 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rdWPC-0005XG-D8 for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 09:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Feb 2024 14:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68509 X-GNU-PR-Package: emacs Original-Received: via spool by 68509-submit@debbugs.gnu.org id=B68509.170869795521206 (code B ref 68509); Fri, 23 Feb 2024 14:20:02 +0000 Original-Received: (at 68509) by debbugs.gnu.org; 23 Feb 2024 14:19:15 +0000 Original-Received: from localhost ([127.0.0.1]:41233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdWOQ-0005Vx-Gx for submit@debbugs.gnu.org; Fri, 23 Feb 2024 09:19:14 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:42865) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdWOO-0005Vh-Gj for 68509@debbugs.gnu.org; Fri, 23 Feb 2024 09:19:13 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 65A0F240027 for <68509@debbugs.gnu.org>; Fri, 23 Feb 2024 15:01:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1708696897; bh=N3sXhwzMlRPHawtNpjMdv5IatGGBMi6ZLCyFPcjVygM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=pVBcZ/dpdIZaAaAdl6UVXLh42Z2v/iuXREw3TkZFpmBl0epy5smZ8DUA3XjuD3J+h nx+heC2Swli1B5frRg2MPFHv3/GRUZxv7cw3GwUG1NSEC4GIC8LsCz4+u0uoRNwB5X XnAMpSeTJRJs/AG1ooefHPDljyS0eQfwVaQqe8KeAGdkqjfo/SHtp2ZDxs14ccayfj s3eaLYDTryxpGKkEhtKtdV1uJbkqtkYlpaWlzo+zGGn5HE/wMC/0seUj7vjNyDX1Fh oabTXm5ZVAi5f3n60P5axLHiHQh83C6fO6A15fdicc41bL8OreqFmy4iQft6URCAvm M6pCdGkStaR5A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4ThBWg645xz9rxW; Fri, 23 Feb 2024 15:01:35 +0100 (CET) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280495 Archived-At: Stefan Monnier writes: >> May you then describe in more details what is the intended behavior when >> PATTERN does not match VALUE in destructuring? > > How 'bout the patch below? > ... > +The precise behavior when the object does not actually match the pattern > +depends on the types, although the body will not be silently skipped: > +either an error is signaled or the body is run with some of the > +variables bound to arbitrary values like @code{nil}. > +For example, the above pattern will result in @var{x} and @var{y} > +being extracted with operations like @code{car} or @code{nth}, so they > +will get value @code{nil} when @var{my-list} is too short. In contrast, > +with a pattern like @code{`[add ,x ,y]}, those same variables would > +be extracted using @code{aref} which would signal an error if > +@var{my-list} is not an array or is too short. This is confusing. In particular, "for example" implies that other situations are possible. It is unclear how the reader will know when "variables bound to arbitrary values" happen, when variables are bound to nil, and when an error is signaled. I would re-structure the paragraph, explicitly listing the possible outcomes when the PATTERN does not match VALUE and stating that any other non-matching PATTERN will lead to undefined outcome. Also, with the current behavior of `pcase-let', it appears to be impossible to distinguish between too short list (1 2 3) and (1 2 3 nil nil) when assigning destructuring pattern. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at