commit 5d0662dc1c6c087d0f23621a77b29f48895e73a0
parent 874351d34d32f935e3f20485a544681de369c756
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Wed, 14 Feb 2018 19:19:00 +0000
Fix a crash for functions whose body ends with a symbol
Diffstat:
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -1,6 +1,7 @@
# v0.8
-No changes yet.
+Fixed a crash on functions where the last form in their definition is
+a plain symbol.
# v0.7
diff --git a/helpful.el b/helpful.el
@@ -320,7 +320,9 @@ source code to primitives."
;; `edebug-enter', `edebug-after' etc interleaved. This means the
;; function is interpreted, so `indirect-function' returns a list.
(when (and (consp fn-def) (consp (cdr fn-def)))
- (eq (car (-last-item fn-def)) 'edebug-enter))))
+ (-let [fn-end (-last-item fn-def)]
+ (and (consp fn-end)
+ (eq (car fn-end) 'edebug-enter))))))
(defun helpful--can-edebug-p (sym callable-p)
"Can we use edebug with SYM?"
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -88,6 +88,16 @@
(eval (eval-sexp-add-defvars (edebug-read-top-level-form)) t))))
(helpful-function #'test-foo-edebug))
+(defun test-foo-return-arg (s)
+ "blah blah."
+ s)
+
+(ert-deftest helpful--edebug-p ()
+ "Ensure that we don't crash on a function whose body ends with
+symbol (not a form)."
+ (should
+ (not (helpful--edebug-p #'test-foo-return-arg))))
+
(defun test-foo-usage-docstring ()
"\n\n(fn &rest ARGS)"
nil)