From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#43100: 28.0.50; pcase not binding variables conditionally Date: Sat, 29 Aug 2020 09:41:10 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000005fa99805ae00fa25" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25972"; mail-complaints-to="usenet@ciao.gmane.io" To: 43100@debbugs.gnu.org, monnier@iro.umontreal.ca Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 29 11:42:18 2020 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 1kBxNK-0006fK-J1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 11:42:18 +0200 Original-Received: from localhost ([::1]:59920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBxNJ-0000kG-IX for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 05:42:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBxN4-0000k1-HS for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 05:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36386) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBxN4-0001hK-8a for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 05:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kBxN4-0003yf-6k for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 05:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Aug 2020 09:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43100 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.159869411315273 (code B ref -1); Sat, 29 Aug 2020 09:42:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Aug 2020 09:41:53 +0000 Original-Received: from localhost ([127.0.0.1]:47932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBxMv-0003yG-BL for submit@debbugs.gnu.org; Sat, 29 Aug 2020 05:41:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBxMt-0003y9-S4 for submit@debbugs.gnu.org; Sat, 29 Aug 2020 05:41:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBxMt-0000ho-LF for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 05:41:51 -0400 Original-Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]:42839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBxMr-0001eh-8p for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 05:41:51 -0400 Original-Received: by mail-oi1-x22a.google.com with SMTP id j7so2879872oij.9 for ; Sat, 29 Aug 2020 02:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=dK6piiH0w4fTvG90pSaLuk8/aojNP95rKv6u5SUG8pQ=; b=h9nm7P9RJTRJvKR+YXuX7A6nF8r66tksz290rhz+G7Vh7eWD4EMGHrg63bGgj7fHNC gfKruMHvtp8lXnl+KZHRdF+c4neKd1i/qtdh54yE5nWGdZUkcH6t1jnp7SVQqRM5c0iq 5VscWn1LxhI8dymJv3La02bCdYWN79iQJwJgrMNqfueOsxe0lQH/ANHCAHJtMcDqd0ij +dOQzpPxvUSbfJC9OpcqiSjDKL6KuvP9LAETL2PdVK+92lOSTfEwrpnpmFB1amblglGz m2i+PqjCHFb3QUyZyt84ec8dwpQ9QvMzVIH0jwIUs7FSTfmIhfeqAJ5AjZZsMeQYUCpc KCtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=dK6piiH0w4fTvG90pSaLuk8/aojNP95rKv6u5SUG8pQ=; b=ESj9eT4m3VXxTxFPcOTuzinvh8LJFdHf0capuig9aU42HmPjrAohPEuiVAGDXPU93o dDSuoZbhZP5+GqgY67mlnSS2mbBRQu/ZSvJFfDCmfc3rxAXcdPufxtROOxPz921IOoQX +0iFVEi/wPg82QZbF5kXpRTiC+z92fYN4l5bzyyugI1CX++elHus6sGFN8CmXHp+3tmM k5HkElHFhNhcvh9rUWdaBFyk820v1PM00GAhW+Ns5e0BMoREN5EnuKWNUoUNmEpbaSW9 UxSywtUxhQkr9lpA0VbtdoaXHD0BFBWbba8ncM0rSd8PeAkAF/pHrUcsRAQCL9G8Hvta NEqg== X-Gm-Message-State: AOAM533PqHG1/+LTvkAG6NF6Pybd4sMs9WG7Dygx318WmxK2GAGEXahf gL0ZHWtMEaVdn+rGj691xO7aBvy5ILC00jw4xAGgwKVYZZcPbg== X-Google-Smtp-Source: ABdhPJwLDjLfsV1ZGJLiV9atK38xh1xs2AlwoBX/u53KaO3L5hHWchsw/8NKoxvkCr/Kneb+BM7/tcO4EEr0++RTX8s= X-Received: by 2002:aca:dc04:: with SMTP id t4mr1612979oig.30.1598694107350; Sat, 29 Aug 2020 02:41:47 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=pipcet@gmail.com; helo=mail-oi1-x22a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:186635 Archived-At: --0000000000005fa99805ae00fa25 Content-Type: text/plain; charset="UTF-8" I'm having trouble with pcase's behavior. (pcase "a" ((or (pred symbolp) name) (let ((foo 'bar)) name))) throws an error. It shouldn't. (Note that the dummy "let" is necessary to force the pcase code generation to use a function call). I believe the culprit is the code around this comment in pcase.el ;; If some of `vars' were not found in `prevvars', that's ;; OK it just means those vars aren't present in all ;; branches, so they can be used within the pattern ;; (e.g. by a `guard/let/pred') but not in the branch. I believe that's incorrect: using the variable in a condition-case should work, as should conditional shadowing of an existing binding, as in this case: (let ((name "default")) (pcase "a" ((or (pred symbolp) name) name))) (which works), or this case: (let ((name "default")) (pcase "a" ((or (pred symbolp) name) (let ((foo 'bar)) name)))) (which doesn't). I believe the right fix is not to share code for the same branch if it uses different variables, as in the attached patch. It's possible this increases codegen complexity in some construed cases, but in practice that shouldn't be a problem. --0000000000005fa99805ae00fa25 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Allow-variable-bindings-to-differ-across-pcase-alter.patch" Content-Disposition: attachment; filename="0001-Allow-variable-bindings-to-differ-across-pcase-alter.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kefh413x0 RnJvbSBlYzdlNGE5MmFiMDhhZGY0ZWIwMzZlYTUwZjdkNzBiYWRlNjM3MTliIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQaXAgQ2V0IDxwaXBjZXRAZ21haWwuY29tPgpEYXRlOiBTYXQs IDI5IEF1ZyAyMDIwIDA5OjM1OjQxICswMDAwClN1YmplY3Q6IFtQQVRDSF0gQWxsb3cgdmFyaWFi bGUgYmluZGluZ3MgdG8gZGlmZmVyIGFjcm9zcyBwY2FzZSBhbHRlcm5hdGl2ZXMuCgpUaGlzIGZp eGVzIHBjYXNlIGNhc2VzIGxpa2UgKChvciAocHJlZCBzdHJpbmdwKSBuYW1lKSBuYW1lKSwgd2hp Y2gKc2hvdWxkIHVzZSB0aGUgcGNhc2UtbG9jYWwgYmluZGluZyBvbmx5IGlmIEVYUFZBTCBpc24n dCBhIHN0cmluZy4KCiogbGlzcC9lbWFjcy1saXNwL3BjYXNlLmVsIChwY2FzZS0tZXhwYW5kKTog RG8gbm90IHNoYXJlIGNvZGUgaWYKdmFyaWFibGVzIGRpZmZlci4KLS0tCiBsaXNwL2VtYWNzLWxp c3AvcGNhc2UuZWwgfCAzICsrLQogMSBmaWxlIGNoYW5nZWQsIDIgaW5zZXJ0aW9ucygrKSwgMSBk ZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL2xpc3AvZW1hY3MtbGlzcC9wY2FzZS5lbCBiL2xpc3Av ZW1hY3MtbGlzcC9wY2FzZS5lbAppbmRleCBhOGNlMjMyODRjLi43MjkxNjI5NmNiIDEwMDY0NAot LS0gYS9saXNwL2VtYWNzLWxpc3AvcGNhc2UuZWwKKysrIGIvbGlzcC9lbWFjcy1saXNwL3BjYXNl LmVsCkBAIC0zNDYsNyArMzQ2LDggQEAgcGNhc2UtLWV4cGFuZAogICAgICAgICAgICAgKGxhbWJk YSAoY29kZSB2YXJzKQogICAgICAgICAgICAgICAobGV0ICgodmFycyAocGNhc2UtLWZncmVwIHZh cnMgY29kZSkpCiAgICAgICAgICAgICAgICAgICAgIChwcmV2IChhc3NxIGNvZGUgc2VlbikpKQot ICAgICAgICAgICAgICAgIChpZiAobm90IHByZXYpCisgICAgICAgICAgICAgICAgKGlmIChvciAo bm90IHByZXYpCisgICAgICAgICAgICAgICAgICAgICAgICAobm90IChlcXVhbCAoY2FkciBwcmV2 KSB2YXJzKSkpCiAgICAgICAgICAgICAgICAgICAgIChsZXQgKChyZXMgKHBjYXNlLWNvZGVnZW4g Y29kZSB2YXJzKSkpCiAgICAgICAgICAgICAgICAgICAgICAgKHB1c2ggKGxpc3QgY29kZSB2YXJz IHJlcykgc2VlbikKICAgICAgICAgICAgICAgICAgICAgICByZXMpCi0tIAoyLjI4LjAKCg== --0000000000005fa99805ae00fa25--