From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steve Yegge Newsgroups: gmane.emacs.bugs Subject: bug#6415: [PATCH] fix edebug instrumentation of dotted pairs in macros Date: Mon, 26 Sep 2011 10:17:52 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd28a08d11a9204addb563a X-Trace: dough.gmane.org 1317057876 29675 80.91.229.12 (26 Sep 2011 17:24:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 26 Sep 2011 17:24:36 +0000 (UTC) To: 6415@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 26 19:24:32 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R8Eut-0000BO-06 for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Sep 2011 19:24:31 +0200 Original-Received: from localhost ([::1]:48927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Eus-0008ST-2a for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Sep 2011 13:24:30 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Euh-0007pO-B6 for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:24:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8Euf-0002nj-TT for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:24:19 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Euf-0002nd-Qw for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:24:17 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1R8EvN-0000Kk-VO for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:25:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Steve Yegge Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Sep 2011 17:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6415 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13170578591230 (code B ref -1); Mon, 26 Sep 2011 17:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Sep 2011 17:24:19 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R8Eug-0000Jm-7i for submit@debbugs.gnu.org; Mon, 26 Sep 2011 13:24:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R8EpJ-0000Bk-Kw for submit@debbugs.gnu.org; Mon, 26 Sep 2011 13:18:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8EoZ-0001br-MA for submit@debbugs.gnu.org; Mon, 26 Sep 2011 13:18:00 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:33302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8EoZ-0001bn-KX for submit@debbugs.gnu.org; Mon, 26 Sep 2011 13:17:59 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:39449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8EoY-0002hE-De for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:17:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8EoW-0001bK-Ea for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:17:58 -0400 Original-Received: from smtp-out.google.com ([74.125.121.67]:48486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8EoW-0001b6-30 for bug-gnu-emacs@gnu.org; Mon, 26 Sep 2011 13:17:56 -0400 Original-Received: from hpaq11.eem.corp.google.com (hpaq11.eem.corp.google.com [172.25.149.11]) by smtp-out.google.com with ESMTP id p8QHHsmx008409 for ; Mon, 26 Sep 2011 10:17:54 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1317057474; bh=CmxAahY8Zn8GGjJ1ebHUC0xfehM=; h=MIME-Version:Date:Message-ID:Subject:From:To:Content-Type; b=Rl+V8P0RF+LzmktnEWd7lblifywMCrlY3obMsVMok5tGuBDP02AhrL2617cqpBIFP wv/VYfim1/3IlFz0uYTUQ== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=dkim-signature:mime-version:date:message-id:subject:from:to: content-type:x-system-of-record; b=qselpFresaSO8l/8NhZ6op6YLNUUnmgQqYHMCdhbuntGc8T//9H5vu8KZTQlhLh3k cXLvr+oZP/YYdDfj8VCBQ== Original-Received: from yia13 (yia13.prod.google.com [10.243.65.13]) by hpaq11.eem.corp.google.com with ESMTP id p8QHEECP007192 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 26 Sep 2011 10:17:53 -0700 Original-Received: by yia13 with SMTP id 13so5699016yia.13 for ; Mon, 26 Sep 2011 10:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=mime-version:date:message-id:subject:from:to:content-type; bh=VL+4WVaHGxVZ8/V8axrxfnMGTVzzuJ5AkvBDc7RJNx4=; b=HGKVsgmPYAcZgJp+vg8IwkMAbU2nGL0kTVwQ09j8THfFLRvhDAKc6nFl9Ap7jvEH8t aGYEK0LhK4lS7FjAbujg== Original-Received: by 10.150.244.7 with SMTP id r7mr6733855ybh.390.1317057473127; Mon, 26 Sep 2011 10:17:53 -0700 (PDT) Original-Received: by 10.150.244.7 with SMTP id r7mr6733848ybh.390.1317057472829; Mon, 26 Sep 2011 10:17:52 -0700 (PDT) Original-Received: by 10.151.43.13 with HTTP; Mon, 26 Sep 2011 10:17:52 -0700 (PDT) X-System-Of-Record: true X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 26 Sep 2011 13:24:17 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 26 Sep 2011 13:25:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) 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:51895 Archived-At: --000e0cd28a08d11a9204addb563a Content-Type: text/plain; charset=ISO-8859-1 ** Description There were two separate problems conspiring to create this bug. First, the edebug spec for `destructuring-bind' is incorrect. Its definition has three violations of the CL hyperspec for destructuring lambda lists: - it should not support the &environment keyword - it should support the &whole keyword - it should support dotted forms It so happens that the `cl-macro-list1' edebug-spec does all three of these things properly. The second problem is in edebug. The unification algorithm has improper or missing handling for dotted pairs in specs. I chose to add the handling to `edebug-match-specs' since it seemed to be the cleanest place to insert it. ** ChangeLog 2011-09-26 Steve Yegge * emacs-lisp/cl-specs.el: Fixed edebug-spec for `destructuring-bind' to allow dotted pairs in the destructuring lambda list. (Bug#6415) * emacs-lisp/edebug.el: Fixed edebug instrumentation of dotted pairs in edebug specifications for macros. (Bug#6415) ** The patch itself === modified file 'lisp/emacs-lisp/cl-specs.el' --- lisp/emacs-lisp/cl-specs.el 2011-02-11 03:54:12 +0000 +++ lisp/emacs-lisp/cl-specs.el 2011-09-26 16:37:19 +0000 @@ -90,7 +90,7 @@ ((&rest (symbol sexp)) cl-declarations body)) (def-edebug-spec destructuring-bind - (&define cl-macro-list def-form cl-declarations def-body)) + (&define cl-macro-list1 def-form cl-declarations def-body)) ;; Setf === modified file 'lisp/emacs-lisp/edebug.el' --- lisp/emacs-lisp/edebug.el 2011-08-21 17:43:31 +0000 +++ lisp/emacs-lisp/edebug.el 2011-09-26 16:44:39 +0000 @@ -1567,8 +1567,28 @@ (let ((edebug-dotted-spec t));; Containing spec list was dotted. (edebug-match-specs cursor (list specs) remainder-handler))) - ;; Is the form dotted? - ((not (listp (edebug-cursor-expressions cursor)));; allow nil + ;; Special handling for the tail of a dotted form. + ((and + ;; Is the cursor on the tail of a dotted form? + (not (listp (edebug-cursor-expressions cursor)));; allow nil + ;; When matching a dotted form such as (a b . c) against a + ;; spec list that looks like + ;; ([&rest ...] [&optional ...]+ . [&or arg nil]) + ;; ,e.g., the `cl-macro-list1' edebug-spec, then the &rest spec + ;; will consume everything up to the dotted tail (`c' in this + ;; example). At that point the spec list will look like so: + ;; ([&optional ...]+ . [&or arg nil]) + ;; We need to be able to consume zero or more [&optional ...] + ;; spec(s) without moving the cursor or signaling an error. + ;; The current continuation provides no state that tells us + ;; about the upcoming &optional specs, so we use lookahead: + + ;; Recurse normally if we're about to process an optional spec. + (not (eq (car specs) '&optional)) + ;; Recurse normally if the spec is a dotted list. + (not (and (listp specs) + (not (listp (cdr (last specs))))))) + ;; Otherwise we need to be on the tail of a dotted spec. (if (not edebug-dotted-spec) (edebug-no-match cursor "Dotted spec required.")) ;; Cancel dotted spec and dotted form. --000e0cd28a08d11a9204addb563a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
** Description

There were two separate proble= ms conspiring to create this bug.

First, the edebu= g spec for `destructuring-bind' is incorrect.
Its definition = has three violations of the CL hyperspec for
destructuring lambda lists:

=A0 - it should n= ot support the &environment keyword
=A0 - it should support t= he &whole keyword
=A0 - it should support dotted forms
<= div>
It so happens that the `cl-macro-list1' edebug-spec does= all three
of these things properly.

The= second problem is in edebug. =A0The unification algorithm has
improper or missing handling for dotted pairs in specs. =A0I chose
to add the handling to `edebug-match-specs' since it seemed to be
the cleanest place to insert it.

** ChangeL= og

2011-09-26 =A0Steve Yegge =A0<stevey@google.com>

* emacs-lisp/cl-spe= cs.el: Fixed edebug-spec for
`dest= ructuring-bind' to allow dotted pairs in the
destructuring lambda list.= =A0(Bug#6415)

* emacs-lisp/edebug.el: Fixed edebug instrumentation of
dotted pa= irs in edebug specifications for macros. =A0(Bug#6415)

** The patch itself

=3D=3D=3D = modified file 'lisp/emacs-lisp/cl-specs.el'
--- lisp/emac= s-lisp/cl-specs.el= 2011-02-11 03:54:12 +0000
+++ lisp/emacs-lisp/cl-specs.el 2011-09-26 16:37:19 +0000
@@ -90,7 +90,= 7 @@
=A0 =A0((&rest (symbol sexp)) cl-declarations body))
=A0
=A0(def-edebug-spec destructuring-bind
- =A0(&d= efine cl-macro-list def-form cl-declarations def-body))
+ =A0(&am= p;define cl-macro-list1 def-form cl-declarations def-body))
=A0
=A0;; Setf
=A0

=3D=3D=3D modified file &= #39;lisp/emacs-lisp/edebug.el'
--- lisp/emacs-lisp/edebug.el<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> 2011-08-21 = 17:43:31 +0000
+++ lisp/emacs-lisp/edebug.el 2011-09-26 16:44:39 +0000
@@ -1567,8 +156= 7,28 @@
=A0 =A0 =A0 =A0(let ((edebug-dotted-spec t));; Containing= spec list was dotted.
=A0 (e= debug-match-specs cursor (list specs) remainder-handler)))
=A0
- =A0 =A0 ;; Is the form dotted?
- =A0 =A0 ((not (listp (= edebug-cursor-expressions cursor)));; allow nil
+ =A0 =A0 ;; Special handling for the tail of a dotted form.
+ =A0 =A0 ((and
+ =A0 =A0 =A0 ;; Is the cursor on the tail of a = dotted form?
+ =A0 =A0 =A0 (not (listp (edebug-cursor-expressions= cursor)));; allow nil
+ =A0 =A0 =A0 ;; When matching a dotted form such as (a b . c) against= a
+ =A0 =A0 =A0 ;; spec list that looks like
+ =A0 =A0= =A0 ;; =A0 =A0 ([&rest ...] [&optional ...]+ . [&or arg nil])<= /div>
+ =A0 =A0 =A0 ;; ,e.g., the `cl-macro-list1' edebug-spec, the= n the &rest spec
+ =A0 =A0 =A0 ;; will consume everything up to the dotted tail (`c'= ; in this
+ =A0 =A0 =A0 ;; example). =A0At that point the spec li= st will look like so:
+ =A0 =A0 =A0 ;; =A0 =A0 ([&optional ..= .]+ . [&or arg nil])
+ =A0 =A0 =A0 ;; We need to be able to consume zero or more [&opti= onal ...]
+ =A0 =A0 =A0 ;; spec(s) without moving the cursor or s= ignaling an error.
+ =A0 =A0 =A0 ;; The current continuation prov= ides no state that tells us
+ =A0 =A0 =A0 ;; about the upcoming &optional specs, so we use loo= kahead:
+
+ =A0 =A0 =A0 ;; Recurse normally if we'r= e about to process an optional spec.
+ =A0 =A0 =A0 (not (eq (car = specs) '&optional))
+ =A0 =A0 =A0 ;; Recurse normally if the spec is a dotted list.
<= div>+ =A0 =A0 =A0 (not (and (listp specs)
+ =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 (not (listp (cdr (last specs)))))))
+ =A0 =A0 =A0;; O= therwise we need to be on the tail of a dotted spec.
=A0 =A0 =A0 =A0(if (not edebug-dotted-spec)
=A0 =A0(edebug-no-match = cursor "Dotted spec required."))
=A0 =A0 =A0 =A0;; Canc= el dotted spec and dotted form.

--000e0cd28a08d11a9204addb563a--