GNU bug report logs - #6415
23.1.50; edebug-eval-defun errors on dotted pair in some macros

Previous Next

Package: emacs;

Reported by: Geoff Gole <geoffgole <at> gmail.com>

Date: Sun, 13 Jun 2010 18:06:01 UTC

Severity: normal

Tags: confirmed, patch

Merged with 6566, 15587, 24885

Found in versions 23.1.50, 23.2, 26.0.50

Done: Gemini Lasswell <gazally <at> runbox.com>

Bug is archived. No further changes may be made.

Full log


Message #15 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Steve Yegge <stevey <at> google.com>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#6415: [PATCH] fix edebug instrumentation of dotted pairs in macros
Date: Mon, 26 Sep 2011 10:17:52 -0700
[Message part 1 (text/plain, inline)]
** 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  <stevey <at> google.com>

* 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.
[Message part 2 (text/html, inline)]

This bug report was last modified 7 years and 182 days ago.

Previous Next


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