From ec7e4a92ab08adf4eb036ea50f7d70bade63719b Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 29 Aug 2020 09:35:41 +0000 Subject: [PATCH] Allow variable bindings to differ across pcase alternatives. This fixes pcase cases like ((or (pred stringp) name) name), which should use the pcase-local binding only if EXPVAL isn't a string. * lisp/emacs-lisp/pcase.el (pcase--expand): Do not share code if variables differ. --- lisp/emacs-lisp/pcase.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index a8ce23284c..72916296cb 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -346,7 +346,8 @@ pcase--expand (lambda (code vars) (let ((vars (pcase--fgrep vars code)) (prev (assq code seen))) - (if (not prev) + (if (or (not prev) + (not (equal (cadr prev) vars))) (let ((res (pcase-codegen code vars))) (push (list code vars res) seen) res) -- 2.28.0