]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix dynamic binding wrapper in iter-lambda (bug#25965)
authorGemini Lasswell <gazally@runbox.com>
Thu, 5 Oct 2017 19:41:35 +0000 (12:41 -0700)
committerGemini Lasswell <gazally@runbox.com>
Thu, 5 Oct 2017 19:43:15 +0000 (12:43 -0700)
* lisp/emacs-lisp/generator.el (cps--make-dynamic-binding-wrapper):
Remove extra evaluation of form.
* test/lisp/emacs-lisp/generator-tests.el
(cps-iter-lambda-with-dynamic-binding): New test.

lisp/emacs-lisp/generator.el
test/lisp/emacs-lisp/generator-tests.el

index f3597cc387d7c8e07f604bb74c747b6a145b4a41..3e9885900cfce2cb446cfb5cefd5503cbe82828b 100644 (file)
@@ -142,8 +142,7 @@ the CPS state machinery.
     `(let ((,dynamic-var ,static-var))
        (unwind-protect ; Update the static shadow after evaluation is done
             ,form
-         (setf ,static-var ,dynamic-var))
-       ,form)))
+         (setf ,static-var ,dynamic-var)))))
 
 (defmacro cps--with-dynamic-binding (dynamic-var static-var &rest body)
   "Evaluate BODY such that generated atomic evaluations run with
index 4cc6c841dac92d2d5fb255ec2902c5a37cb0b7fe..cbb136ae9194ba3ea4662f81c852aabe72c20fdf 100644 (file)
@@ -282,3 +282,13 @@ identical output.
 (ert-deftest cps-test-declarations-preserved ()
   (should (equal (documentation 'generator-with-docstring) "Documentation!"))
   (should (equal (get 'generator-with-docstring 'lisp-indent-function) 5)))
+
+(ert-deftest cps-iter-lambda-with-dynamic-binding ()
+  "`iter-lambda' with dynamic binding produces correct result (bug#25965)."
+  (should (= 1
+             (iter-next
+              (funcall (iter-lambda ()
+                         (let* ((fill-column 10) ;;any special variable will do
+                                (i 0)
+                                (j (setq i (1+ i))))
+                           (iter-yield i))))))))