1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Body of dynamic let-bindings is not in tail position

This fixes a known bug in `named-let`.

* lisp/emacs-lisp/cl-macs.el (cl--self-tco): Prevent TCO from inside
dynamic variable bindings.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test.
This commit is contained in:
Mattias Engdegård 2021-12-20 11:59:22 +01:00
parent 8706f6fde1
commit 92ffe44834
2 changed files with 26 additions and 4 deletions

View file

@ -2139,9 +2139,14 @@ Like `cl-flet' but the definitions can refer to previous ones.
;; setq the fresh new `ofargs' vars instead ;-)
(let ((shadowings
(mapcar (lambda (b) (if (consp b) (car b) b)) bindings)))
;; If `var' is shadowed, then it clearly can't be
;; tail-called any more.
(not (memq var shadowings)))))
(and
;; If `var' is shadowed, then it clearly can't be
;; tail-called any more.
(not (memq var shadowings))
;; If any of the new bindings is a dynamic
;; variable, the body is not in tail position.
(not (cl-some #'macroexp--dynamic-variable-p
shadowings))))))
`(,(car exp) ,bindings . ,(funcall opt-exps exps)))
((and `(condition-case ,err-var ,bodyform . ,handlers)
(guard (not (eq err-var var))))