From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bruno Barbier Newsgroups: gmane.emacs.bugs Subject: bug#70597: Problem in pcase-let? Date: Sat, 27 Apr 2024 18:11:41 +0200 Message-ID: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29770"; mail-complaints-to="usenet@ciao.gmane.io" To: Marco Antoniotti , 70597@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 27 18:12:59 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 1s0kfb-0007Xy-MJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Apr 2024 18:12:59 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0kfN-0007co-Ut; Sat, 27 Apr 2024 12:12:45 -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 1s0kfL-0007cg-KV for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2024 12:12:43 -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 1s0kfL-0007yj-Bb for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2024 12:12:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s0kfe-0000AQ-69 for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2024 12:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Bruno Barbier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Apr 2024 16:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70597 X-GNU-PR-Package: emacs Original-Received: via spool by 70597-submit@debbugs.gnu.org id=B70597.1714234331631 (code B ref 70597); Sat, 27 Apr 2024 16:13:02 +0000 Original-Received: (at 70597) by debbugs.gnu.org; 27 Apr 2024 16:12:11 +0000 Original-Received: from localhost ([127.0.0.1]:49566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0kep-0000A7-AH for submit@debbugs.gnu.org; Sat, 27 Apr 2024 12:12:11 -0400 Original-Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:61571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0ken-00009y-22 for 70597@debbugs.gnu.org; Sat, 27 Apr 2024 12:12:09 -0400 Original-Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2dfb4ea2bbfso7965881fa.2 for <70597@debbugs.gnu.org>; Sat, 27 Apr 2024 09:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714234304; x=1714839104; darn=debbugs.gnu.org; h=mime-version:date:references:in-reply-to:subject:to:from:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2H/csHbUBFMBM838gGnS+ITTAqmW/4eBB5ixSQ9UJYw=; b=ZbCH3ANjtLOq33u5Yp67iDxOuKumD4QIjuFkt0WkvXUVqvzn05aEubLfVCBL8Hr07n v4ZJuqHyUM+vfLCJNE4/p5etvrg3R/8QOWuMAnJ8oMJXTRnyGCH3lPq7np5ApeYlqJyA b7DKwGYdKP48MaDt7Y+wIw8Trsl+bOMKpDjrahNYrvAFqmvLJF3V5JDFauDLVLUGhbCN syic3xShIjXbrSOSZSr8N5I0Y+iaPLW683oiFkJAEtnya3U3I5Y0SI67wwyqFGAyEVr4 Uq5627tAmvpClhZE9QfIGkN4XdYSipK6lpt4QJzCjfIBWsA6UPRO5j89V4pz5YgFp19x LZrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714234304; x=1714839104; h=mime-version:date:references:in-reply-to:subject:to:from:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2H/csHbUBFMBM838gGnS+ITTAqmW/4eBB5ixSQ9UJYw=; b=aOx5eRjTDizyyJ7z2L80LLCtgj6bjFA1QloE5ZoxMGlMPZNaikjvAZPDunRFh3Hbck wHgfkW6xidffkkqB83rL+K03VyFpPWBSuNL84LqfW9H6SBiCsMbcxg0jgLBW0UOWjvMV 1dYNXk5HrdbHECCV26SS+DjWuJFRz6Sokn47fxt0jzfeffG76PASVjkZTbg6GuiSOqvo vn7jqRnY4yU+U41xHKNyDEvdBiLu6byLg+F3F7G6fZIAJeghDAExEUpbEshX4swpZs7E EjcW6nk0aocfWRyIe9DbXR4iZtmZPz1LFdUog4CoYeu94M1LRiwe0RplRiOTAJ/NwAXY jbFQ== X-Forwarded-Encrypted: i=1; AJvYcCW1cA7GhNhoGRsHtaOYqTi2rwyxTik9B5pT8TGhvy6e1aAZ4utdclwh+IddQoqVr3xouRyX7lwkTVz4Q1GsIjHxy5a5NgY= X-Gm-Message-State: AOJu0Yzc4Nhifw7LsTxZrCRvBFQkkLRIogYREc3Ys9R0RLrzjJF+7JGK CIgMHb5ON3kKEgUbxtNKMmeVrHBzJlEPvkV6QXt0VmYblMgC/MD9 X-Google-Smtp-Source: AGHT+IEwuxWPnLE2eok8TXH8u9mGUTBiX2wA/w6UtyDebTYqfEmMvvG7VlReqm6A24IKqgW4C6zdHw== X-Received: by 2002:a2e:9545:0:b0:2da:bbf4:81b8 with SMTP id t5-20020a2e9545000000b002dabbf481b8mr3088454ljh.14.1714234303638; Sat, 27 Apr 2024 09:11:43 -0700 (PDT) Original-Received: from keynux ([2a01:e0a:505:3460:1c18:688d:ece4:372e]) by smtp.gmail.com with ESMTPSA id r21-20020a05600c35d500b0041bf45c0665sm1218855wmq.15.2024.04.27.09.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 09:11:43 -0700 (PDT) Original-Received: by keynux (sSMTP sendmail emulation); Sat, 27 Apr 2024 18:11:41 +0200 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:284056 Archived-At: Hi Marco, I'm not a maintainer but let me try to explain; I'm sure someone will correct me if I'm wrong. In short: not a bug. If I read your examples correctly, your problem could be reduced to this: (using org mode syntax, I hope it's ok): #+begin_src elisp (pcase-let ((`(A *,c . ,r) '(A *1 2 3))) (list c r)) #+end_src #+RESULTS: : (2 (3)) #+begin_src elisp (pcase-let ((`(A *,c . ,r) '(B *1 2 3))) (list c r)) #+end_src #+RESULTS: : (2 (3)) #+begin_src elisp (pcase '(A *1 2 3) (`(B *,c . ,r) (list c r))) #+end_src #+RESULTS: : nil The pcase-let documentation (describe-function 'pcase-let) says this: | Each EXP should match its respective PATTERN (i.e. be of structure | compatible to PATTERN); a mismatch may signal an error or may go | undetected, binding variables to arbitrary values, such as nil. Both of your pcase-let examples are actually undefined, because the patterns don't match in *both* cases. pcase-let works as documented: it did bind some variables to arbitrary values. That one matches (note the space between * and 1): #+begin_src elisp (pcase-let ((`(A * ,c . ,r) '(A * 1 2 3))) (list c r)) #+end_src #+RESULTS: : (1 (2 3)) That one doesn't match either (replacing * with WORD), but same result that your 2 pcase-let examples: #+begin_src elisp (pcase-let ((`(A *,c . ,r) '(A WORD1 2 3))) (list c r)) #+end_src #+RESULTS: : (2 (3)) Note that *1 is one symbol whose name is "*1". Your pattern `(*,c) is looking for the symbol whose name is "*", followed by the value for c. You may test your pattern, manually binding c to some value, to see that you get a list containing 2 values: #+begin_src elisp (let ((c 1)) `(*,c)) #+end_src #+RESULTS: : (* 1) Hoping this helps, Bruno