unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Richard Copley <rcopley@gmail.com>
Cc: 20281-done@debbugs.gnu.org
Subject: bug#20281: `edebug-eval-defun' mishandles lambda expressions
Date: Wed, 08 Apr 2015 21:48:58 -0400	[thread overview]
Message-ID: <jwva8yiqfix.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <CAPM58oi-TY3YgjrxC8+5KUp9hXwdvqkxyKSv_OuU=jrCWWf00A@mail.gmail.com> (Richard Copley's message of "Wed, 8 Apr 2015 21:44:10 +0100")

> (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	other threads:[~2015-04-09  1:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 20:44 bug#20281: `edebug-eval-defun' mishandles lambda expressions Richard Copley
2015-04-09  1:48 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwva8yiqfix.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=20281-done@debbugs.gnu.org \
    --cc=rcopley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).