# HG changeset patch # User Aidan Kehoe # Date 1323808112 0 # Node ID 2c20bc575989a4cbda81d72a048d74f2665327ef # Parent d489e88450aa0e1139f9300fcbef034172edd8c7 Use the old #'labels implementation if #'lexical-let changes lambdas. lisp/ChangeLog addition: 2011-12-13 Aidan Kehoe * bytecomp.el (byte-compile-initial-macro-environment): If lexical let has played with our lambas, give up on constructing the compiled functions at compiled time, that strategy doesn't work. diff -r d489e88450aa -r 2c20bc575989 lisp/ChangeLog --- a/lisp/ChangeLog Sat Dec 10 16:19:16 2011 +0000 +++ b/lisp/ChangeLog Tue Dec 13 20:28:32 2011 +0000 @@ -3,6 +3,13 @@ * mule/mule-cmds.el (posix-charset-to-coding-system-hash): Correct the docstring for this variable. +2011-12-13 Aidan Kehoe + + * bytecomp.el (byte-compile-initial-macro-environment): + If lexical let has played with our lambas, give up on constructing + the compiled functions at compiled time, that strategy doesn't + work. + 2011-12-09 Aidan Kehoe * cl-macs.el (load-time-value): diff -r d489e88450aa -r 2c20bc575989 lisp/bytecomp.el --- a/lisp/bytecomp.el Sat Dec 10 16:19:16 2011 +0000 +++ b/lisp/bytecomp.el Tue Dec 13 20:28:32 2011 +0000 @@ -636,9 +636,31 @@ (cons 'progn (byte-compile-transform-labels form names lambdas placeholders)))))) - (cl-macroexpand-all `(,gensym ',names (list ,@lambdas) - ',placeholders ,@body) - byte-compile-macro-environment))))) + (setq body + (cl-macroexpand-all `(,gensym ',names (list ,@lambdas) + ',placeholders ,@body) + byte-compile-macro-environment)) + (if (position 'lambda (mapcar #'(lambda (object) + (car-safe (cdr-safe + object))) + (cdr (third body))) + :key #'car-safe :test-not #'eq) + ;; #'lexical-let has worked its magic, not all the + ;; lambdas are lambdas. Give up on pre-compiling the + ;; labels. + (setq names (mapcar #'copy-symbol names) + lambdas (cdr (third body)) + body (sublis (pairlis placeholders names) + (nthcdr 4 body) :test #'eq) + lambdas (sublis (pairlis placeholders names) + lambdas :test #'eq) + body (cl-macroexpand-all + `(lexical-let + ,names + (setf ,@(mapcan #'list names lambdas)) + ,@body) + byte-compile-macro-environment)) + body))))) (flet . ,#'(lambda (bindings &rest body) (let* ((names (mapcar 'car bindings))