# HG changeset patch # User Aidan Kehoe # Date 1315605031 -3600 # Node ID b039c0f018b81507efbf95589e9ad11eaae6d45f # Parent 3bc58dc9d6886c4c584c5f62805e77447e8496c7 Error if byte-compiling a form hasn't wrapped byte-compile-inbuffer. lisp/ChangeLog addition: 2011-09-09 Aidan Kehoe * bytecomp.el (byte-compile-from-buffer): If compiling a form has changed the current buffer (that is, some eval-when-compile form hasn't done save-excursion when appropriate), error and exit; we can't guarantee we'll give useful code in that context. See http://mid.gmane.org/20110909110831.GD2875@acm.acm and related discussion. diff -r 3bc58dc9d688 -r b039c0f018b8 lisp/ChangeLog --- a/lisp/ChangeLog Wed Sep 07 21:21:36 2011 +0100 +++ b/lisp/ChangeLog Fri Sep 09 22:50:31 2011 +0100 @@ -1,3 +1,13 @@ +2011-09-09 Aidan Kehoe + + * bytecomp.el (byte-compile-from-buffer): + If compiling a form has changed the current buffer (that is, some + eval-when-compile form hasn't done save-excursion when + appropriate), error and exit; we can't guarantee we'll give useful + code in that context. See + http://mid.gmane.org/20110909110831.GD2875@acm.acm and related + discussion. + 2011-09-07 Aidan Kehoe * simple.el (transpose-subr): diff -r 3bc58dc9d688 -r b039c0f018b8 lisp/bytecomp.el --- a/lisp/bytecomp.el Wed Sep 07 21:21:36 2011 +0100 +++ b/lisp/bytecomp.el Fri Sep 09 22:50:31 2011 +0100 @@ -1864,7 +1864,11 @@ (looking-at ";")) (forward-line 1)) (not (eobp))) - (byte-compile-file-form (read byte-compile-inbuffer))) + (byte-compile-file-form (read byte-compile-inbuffer)) + (or (eq byte-compile-inbuffer (current-buffer)) + (error 'invalid-state + "byte compiling didn't save-excursion appropriately" + (current-buffer)))) ;; Compile pending forms at end of file. (byte-compile-flush-pending)