From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68509: 30.0.50; pcase-dolist matches backquote pattern incorrectly Date: Mon, 19 Feb 2024 21:46:12 -0500 Message-ID: References: <87a5p5l3jm.fsf@localhost> <9bc2bd05-5fdb-9d5a-3d98-c344c7275027@gmail.com> <87zfvw720q.fsf@localhost> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33182"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Jim Porter , 68509@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 20 03:46:57 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 1rcG9o-0008SF-Oj for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Feb 2024 03:46:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcG9a-0007Xj-AL; Mon, 19 Feb 2024 21:46:42 -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 1rcG9Z-0007XW-Az for bug-gnu-emacs@gnu.org; Mon, 19 Feb 2024 21:46:41 -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 1rcG9Y-0007TV-T1 for bug-gnu-emacs@gnu.org; Mon, 19 Feb 2024 21:46:41 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcG9u-0005bV-8l for bug-gnu-emacs@gnu.org; Mon, 19 Feb 2024 21:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Feb 2024 02:47: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.170839720321510 (code B ref 68509); Tue, 20 Feb 2024 02:47:02 +0000 Original-Received: (at 68509) by debbugs.gnu.org; 20 Feb 2024 02:46:43 +0000 Original-Received: from localhost ([127.0.0.1]:43979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcG9a-0005as-QP for submit@debbugs.gnu.org; Mon, 19 Feb 2024 21:46:43 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcG9Z-0005ae-8D for 68509@debbugs.gnu.org; Mon, 19 Feb 2024 21:46:41 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 6D197807A5; Mon, 19 Feb 2024 21:46:14 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1708397173; bh=+bdrvZ7HrdjP8tBy6xq5R/tx6EAbgRBAMIJa9oLRti8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DrKcEaJW2oj6t9kNZJm1bcV3LT2OeH257XDnpboaPAZBsFDjqn/umFgz55dLxemFJ Pf9gmDNz6Eo2gkSToNk26z/exWF+mUmuiEakRTG6RLWPPHpjUyMIbrsS9VIvDN9yGE CJi+BHI4sVJVzniWeQrpdWSt34NuCLsaRrxZwE3+EX4EEz2a0HavGQHzbjnvNuf68X OdUrOlSNnuDU/c+6HgcYuQiBwMtWto2s9xzjqlt652Q5S5rF15JOUQDjTo4HramTu7 0dQ36TxaMZ+j4lJl9N3WprY9ggVjVvHrHID/NZ7KWr7Q3I2dRJGu5UpLBQfuAENhWE PmcxcKJHWdOBQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7EE1F8014F; Mon, 19 Feb 2024 21:46:13 -0500 (EST) Original-Received: from pastel (unknown [45.72.205.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 553DE120776; Mon, 19 Feb 2024 21:46:13 -0500 (EST) In-Reply-To: <87zfvw720q.fsf@localhost> (Ihor Radchenko's message of "Mon, 19 Feb 2024 18:16:37 +0000") 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:280302 Archived-At: >> 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. > > May you please elaborate how this example is related to destructuring > from user perspective? It appears to me that you are talking about > implementation details of `pcase', which are elusive to me. I'm just reading aloud what the `(a . ,b) pattern means: it means "VAL has to be a cons, and its car should be equal to `a`" (and in addition to that, we'll extract the `cdr` and put it into the `b` variable). We might want to warn the user that such a pattern in `pcase-let` and `pcase-dolist` is probably an error because the `a` won't actually be checked, so it will behave just like the `(,_ . ,b) pattern. But warning the user that the `consp` check will also be dropped would be annoying because it's not like the users can easily write a different pattern that still behaves the same but does not imply such a `consp` check. Stefan