]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/bytecomp.el (add-to-list): Add handler to check the
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 21 Jun 2011 01:43:56 +0000 (21:43 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 21 Jun 2011 01:43:56 +0000 (21:43 -0400)
variable's status.

lisp/ChangeLog
lisp/emacs-lisp/bytecomp.el

index 76339320b83723f0b7a4fca7520650d98b220337..f0039e0b6137958e5d8707973a64c65bd0592fcc 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/bytecomp.el (add-to-list): Add handler to check the
+       variable's status.
+
 2011-06-20  Jan Djärv  <jan.h.d@swipnet.se>
 
        * x-dnd.el (x-dnd-version-from-flags)
index 1e7ee315942f5c23bf6eb5f5e972f420fe10fc00..127f93c6858778aa5eef73014655368907139238 100644 (file)
@@ -4244,6 +4244,25 @@ binding slots have been popped."
 (defun byte-compile-form-make-variable-buffer-local (form)
   (byte-compile-keep-pending form 'byte-compile-normal-call))
 
+(byte-defop-compiler-1 add-to-list byte-compile-add-to-list)
+(defun byte-compile-add-to-list (form)
+  ;; FIXME: This could be used for `set' as well, except that it's got
+  ;; its own opcode, so the final `byte-compile-normal-call' needs to
+  ;; be replaced with something else.
+  (pcase form
+    (`(,fun ',var . ,_)
+     (byte-compile-check-variable var 'assign)
+     (if (assq var byte-compile--lexical-environment)
+         (byte-compile-log-warning
+          (format "%s cannot use lexical var `%s'" fun var)
+          nil :error)
+       (unless (or (not (byte-compile-warning-enabled-p 'free-vars))
+                   (boundp var)
+                   (memq var byte-compile-bound-variables)
+                   (memq var byte-compile-free-references))
+         (byte-compile-warn "assignment to free variable `%S'" var)
+         (push var byte-compile-free-references)))))
+  (byte-compile-normal-call form))
 \f
 ;;; tags