diff lisp/cl-macs.el @ 5569:d19b6e3bdf91

#'cl-defsubst-expand; avoid mutually-recursive symbol macros. lisp/ChangeLog addition: 2011-09-10 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (cl-defsubst-expand): Change set 2a6a8da4dd7c of http://mid.gmane.org/19966.17522.332164.615228@parhasard.net wasn't sufficiently comprehensive, symbol macros can be mutually rather than simply recursive, and they can equally hang. Thanks for the bug report, Michael Sperber, and for the test case, Stephen Turnbull.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 10 Sep 2011 13:17:29 +0100
parents 3bc58dc9d688
children 6c76f5b7e2e3
line wrap: on
line diff
--- a/lisp/cl-macs.el	Fri Sep 09 22:50:31 2011 +0100
+++ b/lisp/cl-macs.el	Sat Sep 10 13:17:29 2011 +0100
@@ -3236,10 +3236,20 @@
     (let* ((symbol-macros nil)
            (lets (mapcan #'(lambda (argn argv)
                              (if (or simple (cl-const-expr-p argv))
-                                 (progn (or (eq argn argv)
-					    (push (list argn argv)
-						  symbol-macros))
-                                        (and unsafe (list (list argn argv))))
+                                 (progn 
+				   ;; Avoid infinite loop on symbol macro
+				   ;; expansion, make sure none of the argvs
+				   ;; refer to the symbols in the argns.
+				   (or (block find
+                                         ;; Can't use cl-expr-contains, that
+                                         ;; doesn't descend lambdas:
+					 (subst nil argn argvs :test
+						#'(lambda (elt tree)
+						    (if (eq elt tree)
+							(return-from find t))))
+					 nil)
+				       (push (list argn argv) symbol-macros))
+				   (and unsafe (list (list argn argv))))
                                (list (list argn argv))))
                          argns argvs)))
       `(let ,lets