From 0ded1b41a986229eaa4218095d9c78d1800c0b27 Mon Sep 17 00:00:00 2001 From: Gemini Lasswell Date: Wed, 1 Nov 2017 21:13:02 -0700 Subject: Fix Edebug's handling of dotted specs (bug#6415) * lisp/emacs-lisp/cl-macs.el (cl-destructuring-bind): Use cl-macro-list1 instead of cl-macro-list in Edebug spec. * lisp/emacs-lisp/edebug.el (edebug-after-dotted-spec): Delete unused variable. (edebug-dotted-spec): Add docstring. (edebug-match-specs): Allow &optional and &rest specs to match nothing at the tail of a dotted form. Handle matches of dotted form tails which return non-lists. * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-dotted-forms): New test. * test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el: (edebug-test-code-use-destructuring-bind): New function. --- test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el | 4 ++++ test/lisp/emacs-lisp/edebug-tests.el | 14 ++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'test/lisp/emacs-lisp') diff --git a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el index f52a2b1896c..ca49dcd213d 100644 --- a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el +++ b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el @@ -126,5 +126,9 @@ !start!(with-current-buffer (get-buffer-create "*edebug-test-code-buffer*") !body!(format "current-buffer: %s" (current-buffer)))) +(defun edebug-test-code-use-destructuring-bind () + (let ((two 2) (three 3)) + (cl-destructuring-bind (x . y) (cons two three) (+ x!x! y!y!)))) + (provide 'edebug-test-code) ;;; edebug-test-code.el ends here diff --git a/test/lisp/emacs-lisp/edebug-tests.el b/test/lisp/emacs-lisp/edebug-tests.el index 02f4d1c5abe..f6c016cdf80 100644 --- a/test/lisp/emacs-lisp/edebug-tests.el +++ b/test/lisp/emacs-lisp/edebug-tests.el @@ -899,5 +899,19 @@ test and possibly others should be updated." "@g" (should (equal edebug-tests-@-result '(#("abcd" 1 3 (face italic)) 511)))))) +(ert-deftest edebug-tests-dotted-forms () + "Edebug can instrument code matching the tail of a dotted spec (Bug#6415)." + (edebug-tests-with-normal-env + (edebug-tests-setup-@ "use-destructuring-bind" nil t) + (edebug-tests-run-kbd-macro + "@ SPC SPC SPC SPC SPC SPC" + (edebug-tests-should-be-at "use-destructuring-bind" "x") + (edebug-tests-should-match-result-in-messages "2 (#o2, #x2, ?\\C-b)") + "SPC" + (edebug-tests-should-be-at "use-destructuring-bind" "y") + (edebug-tests-should-match-result-in-messages "3 (#o3, #x3, ?\\C-c)") + "g" + (should (equal edebug-tests-@-result 5))))) + (provide 'edebug-tests) ;;; edebug-tests.el ends here -- cgit v1.2.3 From 700f74e4c8d1b33cdf96dab9586dc41ebccaba7d Mon Sep 17 00:00:00 2001 From: Gemini Lasswell Date: Sun, 5 Nov 2017 21:36:58 -0800 Subject: Fix Edebug specs for if-let* and and-let* (Bug#29236) * test/lisp/emacs-lisp/subr-x.el (if-let*, if-let): Change Edebug spec to cause Edebug to instrument tests the results of which are not bound to symbols (the (VALUEFORM) case). (and-let*): Change Edebug spec to allow empty body. *test/lisp/emacs-lisp/subr-x-tests.el: (subr-x-and-let*-test-group-1): Add missing quote to erroneous form so Edebug will work on this test. --- lisp/emacs-lisp/subr-x.el | 8 +++++--- test/lisp/emacs-lisp/subr-x-tests.el | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'test/lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 9ff742c4331..37bcfc2003d 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -133,7 +133,7 @@ be of the form (VALUEFORM), which is evaluated and checked for nil; i.e. SYMBOL can be omitted if only the test result is of interest." (declare (indent 2) - (debug ((&rest [&or symbolp (symbolp form) (sexp)]) + (debug ((&rest [&or symbolp (symbolp form) (form)]) form body))) (if varlist `(let* ,(setq varlist (internal--build-bindings varlist)) @@ -156,7 +156,9 @@ VARLIST is the same as in `if-let*'." "Bind variables according to VARLIST and conditionally eval BODY. Like `when-let*', except if BODY is empty and all the bindings are non-nil, then the result is non-nil." - (declare (indent 1) (debug when-let*)) + (declare (indent 1) + (debug ((&rest [&or symbolp (symbolp form) (form)]) + body))) (let (res) (if varlist `(let* ,(setq varlist (internal--build-bindings varlist)) @@ -168,7 +170,7 @@ are non-nil, then the result is non-nil." "Bind variables according to SPEC and eval THEN or ELSE. Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)." (declare (indent 2) - (debug ([&or (&rest [&or symbolp (symbolp form) (sexp)]) + (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) (symbolp form)] form body)) (obsolete "use `if-let*' instead." "26.1")) diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index 0e8871d9a9c..0187f39d15d 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -403,7 +403,7 @@ (should-error (eval '(and-let* (nil (x 1))) lexical-binding) :type 'setting-constant) (should (equal nil (and-let* ((nil) (x 1))))) - (should-error (eval (and-let* (2 (x 1))) lexical-binding) + (should-error (eval '(and-let* (2 (x 1))) lexical-binding) :type 'wrong-type-argument) (should (equal 1 (and-let* ((2) (x 1))))) (should (equal 2 (and-let* ((x 1) (2))))) -- cgit v1.2.3