emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/compat e1722e1 2/2: Fix handling of tail-less cond bran


From: ELPA Syncer
Subject: [elpa] externals/compat e1722e1 2/2: Fix handling of tail-less cond branch
Date: Mon, 25 Oct 2021 10:57:09 -0400 (EDT)

branch: externals/compat
commit e1722e10d6d751965076527461046747737e55ac
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Fix handling of tail-less cond branch
    
    Issue and tests contributed by Mattias EngdegÄrd.
---
 compat-28.1.el  | 4 +++-
 compat-tests.el | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/compat-28.1.el b/compat-28.1.el
index d164bad..e6cdbf6 100644
--- a/compat-28.1.el
+++ b/compat-28.1.el
@@ -433,7 +433,9 @@ as the new values of the bound variables in the recursive 
invocation."
                            (if (cdr branch)
                                (cons (car branch)
                                      (funcall tco-progn (cdr branch)))
-                             (list `(progn ,(funcall tco (car branch)) t))))
+                             (let ((var (make-symbol "head")))
+                               `((let ((,var ,(car branch)))
+                                   (and ,var ,(funcall tco var)))))))
                          (cdr expr))))
                  ((eq (car-safe expr) 'or)
                   (if (cddr expr)
diff --git a/compat-tests.el b/compat-tests.el
index ca77efd..89c80d2 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1215,6 +1215,10 @@ the compatibility function."
                         (/ n 0)
                       (arith-error (loop (1- n))))
                   'ok))
+              'ok))
+  (should (eq (compat--named-let loop ((x nil))
+                (cond (x)
+                      (t 'ok)))
               'ok)))
 
 (ert-deftest compat-directory-name-p ()



reply via email to

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