Commit f4d32538 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/emacs-lisp/thunk.el (thunk-delay): Fix memory leak

Get rid of references to the free variables of `body` once the thunk has
been forced (bug#30626).
parent ffb7bbdf
Pipeline #1897 failed with stage
in 3 seconds
...@@ -54,16 +54,15 @@ ...@@ -54,16 +54,15 @@
"Delay the evaluation of BODY." "Delay the evaluation of BODY."
(declare (debug t)) (declare (debug t))
(cl-assert lexical-binding) (cl-assert lexical-binding)
(let ((forced (make-symbol "forced")) `(let (forced
(val (make-symbol "val"))) (val (lambda () ,@body)))
`(let (,forced ,val) (lambda (&optional check)
(lambda (&optional check) (if check
(if check forced
,forced (unless forced
(unless ,forced (setf val (funcall val))
(setf ,val (progn ,@body)) (setf forced t))
(setf ,forced t)) val))))
(defun thunk-force (delayed) (defun thunk-force (delayed)
"Force the evaluation of DELAYED. "Force the evaluation of DELAYED.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment