[Top][All Lists]

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

master e96f78f: Band-aid for edebugging generator bodies (Bug#40434).

From: Philipp Stephani
Subject: master e96f78f: Band-aid for edebugging generator bodies (Bug#40434).
Date: Sun, 14 Jun 2020 14:01:50 -0400 (EDT)

branch: master
commit e96f78fca672c74b7bf1120b7683a50295418725
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    Band-aid for edebugging generator bodies (Bug#40434).
    Edebug doesn't support them well.  Rather than trying to fix Edebug,
    disable instrumentation for now to prevent annoying bugs.
    * lisp/emacs-lisp/generator.el (iter-defun, iter-lambda, iter-make)
    (iter-do): Don't attempt to instrument bodies that are mangled by the
    CPS transformer.
    * test/lisp/emacs-lisp/generator-tests.el
    (generator-tests-edebug): New regression test.
 lisp/emacs-lisp/generator.el            | 8 ++++----
 test/lisp/emacs-lisp/generator-tests.el | 9 +++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el
index ba344eb..c95c758 100644
--- a/lisp/emacs-lisp/generator.el
+++ b/lisp/emacs-lisp/generator.el
@@ -673,7 +673,7 @@ When called as a function, NAME returns an iterator value 
 encapsulates the state of a computation that produces a sequence
 of values.  Callers can retrieve each value using `iter-next'."
   (declare (indent defun)
-           (debug (&define name lambda-list lambda-doc def-body))
+           (debug (&define name lambda-list lambda-doc &rest sexp))
            (doc-string 3))
   (cl-assert lexical-binding)
   (let* ((parsed-body (macroexp-parse-body body))
@@ -687,14 +687,14 @@ of values.  Callers can retrieve each value using 
   "Return a lambda generator.
 `iter-lambda' is to `iter-defun' as `lambda' is to `defun'."
   (declare (indent defun)
-           (debug (&define lambda-list lambda-doc def-body)))
+           (debug (&define lambda-list lambda-doc &rest sexp)))
   (cl-assert lexical-binding)
   `(lambda ,arglist
      ,(cps-generate-evaluator body)))
 (defmacro iter-make (&rest body)
   "Return a new iterator."
-  (declare (debug t))
+  (declare (debug (&rest sexp)))
   (cps-generate-evaluator body))
 (defconst iter-empty (lambda (_op _val) (signal 'iter-end-of-sequence nil))
@@ -720,7 +720,7 @@ is blocked."
 Evaluate BODY with VAR bound to each value from ITERATOR.
 Return the value with which ITERATOR finished iteration."
   (declare (indent 1)
-           (debug ((symbolp form) body)))
+           (debug ((symbolp form) &rest sexp)))
   (let ((done-symbol (cps--gensym "iter-do-iterator-done"))
         (condition-symbol (cps--gensym "iter-do-condition"))
         (it-symbol (cps--gensym "iter-do-iterator"))
diff --git a/test/lisp/emacs-lisp/generator-tests.el 
index bcfab20..9b1a573 100644
--- a/test/lisp/emacs-lisp/generator-tests.el
+++ b/test/lisp/emacs-lisp/generator-tests.el
@@ -304,4 +304,13 @@ identical output."
                                             (1+ it)))))))
+(ert-deftest generator-tests-edebug ()
+  "Check that Bug#40434 is fixed."
+  (with-temp-buffer
+    (prin1 '(iter-defun generator-tests-edebug ()
+              (iter-yield 123))
+           (current-buffer))
+    (edebug-defun))
+  (should (eql (iter-next (generator-tests-edebug)) 123)))
 ;;; generator-tests.el ends here

reply via email to

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