branch: externals/compat
commit e1722e10d6d751965076527461046747737e55ac
Author: Philip Kaludercic <[email protected]>
Commit: Philip Kaludercic <[email protected]>
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 ()