bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20281: `edebug-eval-defun' mishandles lambda expressions


From: Stefan Monnier
Subject: bug#20281: `edebug-eval-defun' mishandles lambda expressions
Date: Wed, 08 Apr 2015 21:48:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> (defun test ()
>   (funcall (lambda () "a string")))
> Evaluate the following form:
> (test)
> The result is nil.

Indeed.  I see this behavior at least since Emacs-20 (my Emacs-19
binary is behaving funny right now).

That's because of

   (def-edebug-spec defun
     (&define name lambda-list
           [&optional stringp]
           [&optional ("interactive" interactive)]
           def-body))

which solves the ambiguity in your example as "the string is a docstring
and the def-body is simply empty" instead of "there's no docstring and
the def-body contains a single expression which is a string".

I tried

   (def-edebug-spec defun
     (&define name lambda-list
              &or def-form
              [[&optional stringp]
               [&optional ("interactive" interactive)]
               def-body]))

but that didn't worked right either.  Instead of digging deeper into the
Edebug spec, I installed the patch below which seems to fix
this problem.


        Stefan


diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index aa7cdf9..d0668bb 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -1869,8 +1869,13 @@ expressions; a `progn' form will be returned enclosing 
these forms."
   ;; Like body but body is wrapped in edebug-enter form.
   ;; The body is assumed to be executing inside of the function context.
   ;; Not to be used otherwise.
-  (let ((edebug-inside-func t))
-    (list (edebug-wrap-def-body (edebug-forms cursor)))))
+  (let* ((edebug-inside-func t)
+         (forms (edebug-forms cursor)))
+    ;; If there's no form, there's nothing to wrap!
+    ;; This happens to handle bug#20281, tho maybe a better fix would be to
+    ;; improve the `defun' spec.
+    (when forms
+      (list (edebug-wrap-def-body forms)))))
 
 
 ;;;; Edebug Form Specs





reply via email to

[Prev in Thread] Current Thread [Next in Thread]