]> git.eshelyaron.com Git - emacs.git/commitdiff
Do call debugger on failed cl-assert
authorNoam Postavsky <npostavs@gmail.com>
Tue, 8 Nov 2016 01:03:48 +0000 (20:03 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Wed, 9 Nov 2016 00:54:03 +0000 (19:54 -0500)
"Don't call debug on failed cl-assert..." removed the call to `debug' in
cl--assertion-failed because `debug' calls `kill-emacs' in batch mode,
thus messing up ert test runs.  However, calling the debugger is useful
because it allows catching failed assertions even inside
`condition-case' calls.  The problem with ert can be avoided by calling
`debugger' instead of `debug' directly, since ert installs its own
debugger while running tests.

* lisp/emacs-lisp/cl-preloaded.el (cl--assertion-failed): Call
`debugger' if `debug-on-error' is non-nil.

lisp/emacs-lisp/cl-preloaded.el

index 639ffa64b8cbdae6d99cebde12e1460d0db1c466..2b022c490536485fc45e8c207b81b90d98de668c 100644 (file)
 (define-error 'cl-assertion-failed (purecopy "Assertion failed"))
 
 (defun cl--assertion-failed (form &optional string sargs args)
-  (if string
-      (apply #'error string (append sargs args))
-    (signal 'cl-assertion-failed `(,form ,@sargs))))
+  (if debug-on-error
+      (funcall debugger `(cl-assertion-failed ,form ,string ,@sargs))
+    (if string
+        (apply #'error string (append sargs args))
+      (signal 'cl-assertion-failed `(,form ,@sargs)))))
 
 ;; When we load this (compiled) file during pre-loading, the cl--struct-class
 ;; code below will need to access the `cl-struct' info, since it's considered