emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d56b1f9: * lisp/emacs-lisp/pcase.el (pcase--split-pred): Re-fix b


From: Stefan Monnier
Subject: master d56b1f9: * lisp/emacs-lisp/pcase.el (pcase--split-pred): Re-fix bug#14773
Date: Mon, 1 Mar 2021 14:07:11 -0500 (EST)

branch: master
commit d56b1f9e7cee077011fa1256c2965c2984a17282
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/emacs-lisp/pcase.el (pcase--split-pred): Re-fix bug#14773
    
    Adjust to calling convention of `macroexp--fgrep`.
---
 lisp/emacs-lisp/pcase.el            | 2 +-
 test/lisp/emacs-lisp/pcase-tests.el | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index 95e5dd3..b1e1305 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -661,7 +661,7 @@ A and B can be one of:
                ;; run, but we don't have the environment in which `pat' will
                ;; run, so we can't do a reliable verification.  But let's try
                ;; and catch at least the easy cases such as (bug#14773).
-               (not (macroexp--fgrep (mapcar #'car vars) (cadr upat)))))
+               (not (macroexp--fgrep vars (cadr upat)))))
       '(:pcase--succeed . :pcase--fail))
      ;; In case PAT is of the form (pred (not PRED))
      ((and (eq 'pred (car-safe pat)) (eq 'not (car-safe (cadr pat))))
diff --git a/test/lisp/emacs-lisp/pcase-tests.el 
b/test/lisp/emacs-lisp/pcase-tests.el
index e6f4c09..1438411 100644
--- a/test/lisp/emacs-lisp/pcase-tests.el
+++ b/test/lisp/emacs-lisp/pcase-tests.el
@@ -75,6 +75,14 @@
 (ert-deftest pcase-tests-vectors ()
   (should (equal (pcase [1 2] (`[,x] 1) (`[,x ,y] (+ x y))) 3)))
 
+(ert-deftest pcase-tests-bug14773 ()
+  (let ((f (lambda (x)
+             (pcase 'dummy
+               ((and (let var x) (guard var)) 'left)
+               ((and (let var (not x)) (guard var)) 'right)))))
+    (should (equal (funcall f t) 'left))
+    (should (equal (funcall f nil) 'right))))
+
 ;; Local Variables:
 ;; no-byte-compile: t
 ;; End:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]