mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 02:51:31 -08:00
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.
This commit is contained in:
parent
62cf8f1649
commit
e96f78fca6
2 changed files with 13 additions and 4 deletions
|
|
@ -673,7 +673,7 @@ When called as a function, NAME returns an iterator value that
|
||||||
encapsulates the state of a computation that produces a sequence
|
encapsulates the state of a computation that produces a sequence
|
||||||
of values. Callers can retrieve each value using `iter-next'."
|
of values. Callers can retrieve each value using `iter-next'."
|
||||||
(declare (indent defun)
|
(declare (indent defun)
|
||||||
(debug (&define name lambda-list lambda-doc def-body))
|
(debug (&define name lambda-list lambda-doc &rest sexp))
|
||||||
(doc-string 3))
|
(doc-string 3))
|
||||||
(cl-assert lexical-binding)
|
(cl-assert lexical-binding)
|
||||||
(let* ((parsed-body (macroexp-parse-body body))
|
(let* ((parsed-body (macroexp-parse-body body))
|
||||||
|
|
@ -687,14 +687,14 @@ of values. Callers can retrieve each value using `iter-next'."
|
||||||
"Return a lambda generator.
|
"Return a lambda generator.
|
||||||
`iter-lambda' is to `iter-defun' as `lambda' is to `defun'."
|
`iter-lambda' is to `iter-defun' as `lambda' is to `defun'."
|
||||||
(declare (indent defun)
|
(declare (indent defun)
|
||||||
(debug (&define lambda-list lambda-doc def-body)))
|
(debug (&define lambda-list lambda-doc &rest sexp)))
|
||||||
(cl-assert lexical-binding)
|
(cl-assert lexical-binding)
|
||||||
`(lambda ,arglist
|
`(lambda ,arglist
|
||||||
,(cps-generate-evaluator body)))
|
,(cps-generate-evaluator body)))
|
||||||
|
|
||||||
(defmacro iter-make (&rest body)
|
(defmacro iter-make (&rest body)
|
||||||
"Return a new iterator."
|
"Return a new iterator."
|
||||||
(declare (debug t))
|
(declare (debug (&rest sexp)))
|
||||||
(cps-generate-evaluator body))
|
(cps-generate-evaluator body))
|
||||||
|
|
||||||
(defconst iter-empty (lambda (_op _val) (signal 'iter-end-of-sequence nil))
|
(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.
|
Evaluate BODY with VAR bound to each value from ITERATOR.
|
||||||
Return the value with which ITERATOR finished iteration."
|
Return the value with which ITERATOR finished iteration."
|
||||||
(declare (indent 1)
|
(declare (indent 1)
|
||||||
(debug ((symbolp form) body)))
|
(debug ((symbolp form) &rest sexp)))
|
||||||
(let ((done-symbol (cps--gensym "iter-do-iterator-done"))
|
(let ((done-symbol (cps--gensym "iter-do-iterator-done"))
|
||||||
(condition-symbol (cps--gensym "iter-do-condition"))
|
(condition-symbol (cps--gensym "iter-do-condition"))
|
||||||
(it-symbol (cps--gensym "iter-do-iterator"))
|
(it-symbol (cps--gensym "iter-do-iterator"))
|
||||||
|
|
|
||||||
|
|
@ -304,4 +304,13 @@ identical output."
|
||||||
(1+ it)))))))
|
(1+ it)))))))
|
||||||
-2)))
|
-2)))
|
||||||
|
|
||||||
|
(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
|
;;; generator-tests.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue