From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#20281: `edebug-eval-defun' mishandles lambda expressions Date: Wed, 08 Apr 2015 21:48:58 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1428544165 3096 80.91.229.3 (9 Apr 2015 01:49:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Apr 2015 01:49:25 +0000 (UTC) Cc: 20281-done@debbugs.gnu.org To: Richard Copley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 09 03:49:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yg1aj-0005Jx-K3 for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Apr 2015 03:49:13 +0200 Original-Received: from localhost ([::1]:55853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yg1aj-0002M8-4P for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Apr 2015 21:49:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yg1ad-0002JM-11 for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 21:49:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yg1aZ-0006YI-Tz for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 21:49:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yg1aZ-0006YE-Rn for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 21:49:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Yg1aZ-0004LN-KL for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 21:49:03 -0400 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Apr 2015 01:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 20281 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 20281@debbugs.gnu.org, monnier@iro.umontreal.ca, rcopley@gmail.com Original-Received: via spool by 20281-done@debbugs.gnu.org id=D20281.142854414116652 (code D ref 20281); Thu, 09 Apr 2015 01:49:03 +0000 Original-Received: (at 20281-done) by debbugs.gnu.org; 9 Apr 2015 01:49:01 +0000 Original-Received: from localhost ([127.0.0.1]:49749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yg1aW-0004KW-KO for submit@debbugs.gnu.org; Wed, 08 Apr 2015 21:49:00 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:56309) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yg1aV-0004K4-71 for 20281-done@debbugs.gnu.org; Wed, 08 Apr 2015 21:48:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnEFAGvvdVRBbthL/2dsb2JhbAA3gVOfQYIugQiBdgEFViMQCw4mEhQYDSSqJIxkDAODPgODcASoOw X-IPAS-Result: AnEFAGvvdVRBbthL/2dsb2JhbAA3gVOfQYIugQiBdgEFViMQCw4mEhQYDSSqJIxkDAODPgODcASoOw X-IronPort-AV: E=Sophos;i="5.01,1,1400040000"; d="scan'208";a="115765657" Original-Received: from 65-110-216-75.cpe.pppoe.ca (HELO pastel.home) ([65.110.216.75]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Apr 2015 21:48:59 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 85B8520AC; Wed, 8 Apr 2015 21:48:58 -0400 (EDT) In-Reply-To: (Richard Copley's message of "Wed, 8 Apr 2015 21:44:10 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:101314 Archived-At: > (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