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#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work as expected Date: Sun, 21 Jul 2024 09:51:04 -0400 Message-ID: References: <87r0d2lfjd.fsf@posteo.de> <87h6dvud8u.fsf@posteo.net> <86tthlidap.fsf@gnu.org> <86frsn55t3.fsf@gnu.org> <865xt0e6wc.fsf@gnu.org> <87ikx0mk4c.fsf@posteo.net> <87sew2ly1n.fsf@posteo.net> 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="8568"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: mekeor@posteo.de, Eli Zaretskii , 71503@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 21 15:52:28 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 1sVWzD-00024J-VH for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Jul 2024 15:52:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVWyw-00025p-5z; Sun, 21 Jul 2024 09:52:10 -0400 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 1sVWyn-00021v-1j for bug-gnu-emacs@gnu.org; Sun, 21 Jul 2024 09:52:01 -0400 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 1sVWym-00065W-5y for bug-gnu-emacs@gnu.org; Sun, 21 Jul 2024 09:52:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sVWyn-0005sT-Rw for bug-gnu-emacs@gnu.org; Sun, 21 Jul 2024 09:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Jul 2024 13:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71503 X-GNU-PR-Package: emacs Original-Received: via spool by 71503-submit@debbugs.gnu.org id=B71503.172156987622534 (code B ref 71503); Sun, 21 Jul 2024 13:52:01 +0000 Original-Received: (at 71503) by debbugs.gnu.org; 21 Jul 2024 13:51:16 +0000 Original-Received: from localhost ([127.0.0.1]:54920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sVWy4-0005rN-9w for submit@debbugs.gnu.org; Sun, 21 Jul 2024 09:51:16 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64235) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sVWy3-0005rC-HU for 71503@debbugs.gnu.org; Sun, 21 Jul 2024 09:51:15 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1515A80836; Sun, 21 Jul 2024 09:51:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1721569865; bh=7iCngnAgL6VTUTCuIR6RLG8y8fIyOiSkMRy4Axd6CiQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=LN8Wu8NqUpRGqCjCbEpUqGO7maRG4bitK7/2GTYDGm1pHabuawoq1jkgR23crvved ANyIXXWWdEREc/U7f0wjKMu+6keUVS074Vw1OzFqoNdwQp8LDh9Jh5K6vYu0aFvpno H/jw70pT1on4hSyfHFq6lkyGIrWKmBJVEhT6d5K/pieKLtTyRHc5m17+Bn48Y8jkVP 1eUjcMuLIMQBH8JfgDLbqDjiYCzXzwlf4ios7tqRxwXmWZySJXs+eJxgfNnJx99k/e h5aRB3vsPxmLNaXMeQvrAcsoRtsjMCSX1DwbpOaEdayx0oG1aMyXd8KrUppdSDDWKp Ob/VUOEkkvZlQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B9631807D7; Sun, 21 Jul 2024 09:51:05 -0400 (EDT) Original-Received: from pastel (unknown [45.72.245.253]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 835E712030F; Sun, 21 Jul 2024 09:51:05 -0400 (EDT) In-Reply-To: <87sew2ly1n.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 21 Jul 2024 12:39:00 +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:289074 Archived-At: > Another confusing behaviour that we should document is that in > > (let ((a nil)) > (funcall > (pcase-lambda (a (and (guard a) b)) > (list a b)) > 1 2)) > > I would expect that the (guard a) would use the nil binding from the > `let' form, but instead it is ignored and b is bound to 2. I am not > sure if this is related to the "destructing" point or not. It most definitely is: the `guard` controls here whether the pattern matches or not, but since it's a destructuring match `pcase` takes it for granted that the pattern does match, so the guard is ignored. What might be more confusing is the scoping, e.g.: (macroexpand '(pcase-lambda ((and (guard a) b) a) (FOO))) => #'(lambda (arg0 a) (pcase-let* (((and (guard a) b) arg0)) (FOO))) so the `a` in the guard refers to the argument that follows rather than to a surrounding `a` binding. Stefan