GNU bug report logs - #20281
`edebug-eval-defun' mishandles lambda expressions

Previous Next

Package: emacs;

Reported by: Richard Copley <rcopley <at> gmail.com>

Date: Wed, 8 Apr 2015 20:45:03 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Richard Copley <rcopley <at> gmail.com>
Subject: bug#20281: closed (Re: bug#20281: `edebug-eval-defun' mishandles
 lambda expressions)
Date: Thu, 09 Apr 2015 01:49:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 20281 <at> debbugs.gnu.org.

-- 
20281: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20281
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 20281-done <at> debbugs.gnu.org
Subject: Re: bug#20281: `edebug-eval-defun' mishandles lambda expressions
Date: Wed, 08 Apr 2015 21:48:58 -0400
> (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

[Message part 3 (message/rfc822, inline)]
From: Richard Copley <rcopley <at> gmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: `edebug-eval-defun' mishandles lambda expressions
Date: Wed, 8 Apr 2015 21:44:10 +0100
Invoke `edebug-eval-defun' (C-u C-M-x) on the following defun:

(defun test ()
  (funcall (lambda () "a string")))

Evaluate the following form:

(test)

The result is nil. It should be "a string".

In GNU Emacs 25.0.50.1 (x86_64-w64-mingw32)
 of 2015-04-08 on MACHINE
Repository revision: a480a51f2425c0b0787ab36779ae2e7ca7c6b527
Windowing system distributor `Microsoft Corp.', version 6.3.9600
Configured using:
 `configure --prefix /c/emacs/emacs-20150408-182745
 --disable-dependency-tracking
 --enable-locallisppath=%emacs_dir%/../site-lisp
 --build=x86_64-w64-mingw32 'CFLAGS=-Og -g' 'CPPFLAGS=-I G:/usr/include
 -I C:/GnuWin32/include' 'LDFLAGS=-L G:/usr/lib -L C:/GnuWin32/lib''

Configured features:
XPM JPEG TIFF GIF PNG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB

Important settings:
  value of $LANG: ENG
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Edebug: edebug-anon65100
Edebug: test
Go...
nil

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils cl-macs gv edebug easymenu
cl-loaddefs pcase cl-lib time-date tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table
w32-win w32-vars tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
w32notify w32 multi-tty emacs)

Memory information:
((conses 16 84665 12866)
 (symbols 56 18916 1)
 (miscs 48 46 94)
 (strings 32 15051 3859)
 (string-bytes 1 400862)
 (vectors 16 10759)
 (vector-slots 8 387923 5057)
 (floats 8 82 268)
 (intervals 56 241 47)
 (buffers 976 11))



This bug report was last modified 10 years and 99 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.