aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPhilipp Stephani2021-03-18 12:40:08 +0100
committerPhilipp Stephani2021-04-10 18:19:49 +0200
commit53dfd85a7f971875e716a55f010ee508bce89eed (patch)
tree3eb0b220ff838287f4d6cd3cd45d19794aceecf7 /test
parentb72571ca49dd16be174f02ed14b460c136c9aaf2 (diff)
downloademacs-53dfd85a7f971875e716a55f010ee508bce89eed.tar.gz
emacs-53dfd85a7f971875e716a55f010ee508bce89eed.zip
Edebug: Disable backtracking when hitting a &define keyword.
Edebug doesn't deal well with backtracking out of definitions, see Bug#41988. Rather than trying to support this rare situation (e.g. by implementing a multipass parser), prevent it by adding an implicit gate. * lisp/emacs-lisp/edebug.el (edebug--match-&-spec-op): Disable backtracking when hitting a &define keyword. * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-duplicate-&define): New unit test. (edebug-tests--duplicate-&define): New helper macro. * doc/lispref/edebug.texi (Backtracking): Mention &define in the list of constructs that disable backtracking. * etc/NEWS: Document new behavior.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/edebug-tests.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/edebug-tests.el b/test/lisp/emacs-lisp/edebug-tests.el
index dcb261c2eb9..7d45432e57e 100644
--- a/test/lisp/emacs-lisp/edebug-tests.el
+++ b/test/lisp/emacs-lisp/edebug-tests.el
@@ -1061,5 +1061,30 @@ backtracking (Bug#42701)."
1061 "edebug-anon10001" 1061 "edebug-anon10001"
1062 "edebug-tests-duplicate-symbol-backtrack")))))) 1062 "edebug-tests-duplicate-symbol-backtrack"))))))
1063 1063
1064(defmacro edebug-tests--duplicate-&define (_arg)
1065 "Helper macro for the ERT test `edebug-tests-duplicate-&define'.
1066The Edebug specification is similar to the one used by `cl-flet'
1067previously; see Bug#41988."
1068 (declare (debug (&or (&define name function-form) (defun)))))
1069
1070(ert-deftest edebug-tests-duplicate-&define ()
1071 "Check that Edebug doesn't backtrack out of `&define' forms.
1072This avoids potential duplicate definitions (Bug#41988)."
1073 (with-temp-buffer
1074 (print '(defun edebug-tests-duplicate-&define ()
1075 (edebug-tests--duplicate-&define
1076 (edebug-tests-duplicate-&define-inner () nil)))
1077 (current-buffer))
1078 (let* ((edebug-all-defs t)
1079 (edebug-initial-mode 'Go-nonstop)
1080 (instrumented-names ())
1081 (edebug-new-definition-function
1082 (lambda (name)
1083 (when (memq name instrumented-names)
1084 (error "Duplicate definition of `%s'" name))
1085 (push name instrumented-names)
1086 (edebug-new-definition name))))
1087 (should-error (eval-buffer) :type 'invalid-read-syntax))))
1088
1064(provide 'edebug-tests) 1089(provide 'edebug-tests)
1065;;; edebug-tests.el ends here 1090;;; edebug-tests.el ends here