comparison 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
comparison
equal deleted inserted replaced
5568:b039c0f018b8 5569:d19b6e3bdf91
3234 (if (cl-simple-exprs-p argvs) 3234 (if (cl-simple-exprs-p argvs)
3235 (setq simple t)) 3235 (setq simple t))
3236 (let* ((symbol-macros nil) 3236 (let* ((symbol-macros nil)
3237 (lets (mapcan #'(lambda (argn argv) 3237 (lets (mapcan #'(lambda (argn argv)
3238 (if (or simple (cl-const-expr-p argv)) 3238 (if (or simple (cl-const-expr-p argv))
3239 (progn (or (eq argn argv) 3239 (progn
3240 (push (list argn argv) 3240 ;; Avoid infinite loop on symbol macro
3241 symbol-macros)) 3241 ;; expansion, make sure none of the argvs
3242 (and unsafe (list (list argn argv)))) 3242 ;; refer to the symbols in the argns.
3243 (or (block find
3244 ;; Can't use cl-expr-contains, that
3245 ;; doesn't descend lambdas:
3246 (subst nil argn argvs :test
3247 #'(lambda (elt tree)
3248 (if (eq elt tree)
3249 (return-from find t))))
3250 nil)
3251 (push (list argn argv) symbol-macros))
3252 (and unsafe (list (list argn argv))))
3243 (list (list argn argv)))) 3253 (list (list argn argv))))
3244 argns argvs))) 3254 argns argvs)))
3245 `(let ,lets 3255 `(let ,lets
3246 (symbol-macrolet 3256 (symbol-macrolet
3247 ;; #### Bug; this will happily substitute in places where the 3257 ;; #### Bug; this will happily substitute in places where the