bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11038: 24.0.94; 24.0.94; cl loop macroexpand fails with (wrong-type-


From: Christopher Schmidt
Subject: bug#11038: 24.0.94; 24.0.94; cl loop macroexpand fails with (wrong-type-argument listp emacs)
Date: Sun, 06 May 2012 16:53:45 +0200

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Indeed, there's a bug in cl-expr-contains because it does not
> correctly handle all forms of Elisp.  This is a very long standing
> bug.  It might be possible to fix it by macro-expanding the code
> before calling cl-expr-contains, but since I'm not familiar with
> `loop' nor with its implementation, I'd rather let someone else write
> the corresponding patch (which may have to wait for 24.2).

Here is an (admittedly very naive) patch.
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2012-05-06 08:43:46 +0000
+++ lisp/ChangeLog      2012-05-06 13:47:05 +0000
@@ -1,3 +1,8 @@
+2012-05-06  Christopher Schmidt  <christopher@ch.ristopher.com>
+
+       * emacs-lisp/cl-macs.el (cl-expr-contains): Handle cons cells
+       whose cdr is not a cons cell correctly (Bug#11038).
+
 2012-05-06  Chong Yidong  <cyd@gnu.org>
 
        * emacs-lisp/tabulated-list.el (tabulated-list-format): Accept

=== modified file 'lisp/emacs-lisp/cl-loaddefs.el'
--- lisp/emacs-lisp/cl-loaddefs.el      2012-04-26 03:18:47 +0000
+++ lisp/emacs-lisp/cl-loaddefs.el      2012-05-06 13:50:33 +0000
@@ -286,7 +286,7 @@
 ;;;;;;  flet progv psetq do-all-symbols do-symbols dotimes dolist
 ;;;;;;  do* do loop return-from return block etypecase typecase ecase
 ;;;;;;  case load-time-value eval-when destructuring-bind function*
-;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" 
"abb2e33c6f61539d69ddbe7c4046261b")
+;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" 
"69f391c482a4981642368c6716aacfc8")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'gensym "cl-macs" "\

=== modified file 'lisp/emacs-lisp/cl-macs.el'
--- lisp/emacs-lisp/cl-macs.el  2012-04-26 03:18:47 +0000
+++ lisp/emacs-lisp/cl-macs.el  2012-05-06 13:36:29 +0000
@@ -146,8 +146,9 @@
   (cond ((equal y x) 1)
        ((and (consp x) (not (memq (car-safe x) '(quote function function*))))
         (let ((sum 0))
-          (while x
+          (while (consp x)
             (setq sum (+ sum (or (cl-expr-contains (pop x) y) 0))))
+          (setq sum (+ sum (or (cl-expr-contains x y) 0)))
           (and (> sum 0) sum)))
        (t nil)))
 

I grepped through the sources of cl.*\.el.  cl-expr-contains and
cl-expr-contains-any are not specific to the loop implementation.  I
think the functions do what their names say, inspect an expression and
count occurrences of symbols.  The comment above cl-expr-contains says
so as well (";;; Count number of times X refers to Y.  Return nil for 0
times.").

I tested my patch for a few hours with my configuration that makes heavy
use of cl.  I have not run in any problem so far.

        Christopher

reply via email to

[Prev in Thread] Current Thread [Next in Thread]