[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/bytecomp.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/bytecomp.el |
Date: |
Sat, 29 Aug 2009 14:44:50 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 09/08/29 14:44:50
Modified files:
lisp : ChangeLog
lisp/emacs-lisp: bytecomp.el
Log message:
(byte-compile-const-symbol-p):
Recognize immutable variables like most-positive-fixnum.
(byte-compile-setq-default): Check and warn if trying to assign
to an immutable variable, or a non-variable.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16046&r2=1.16047
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/bytecomp.el?cvsroot=emacs&r1=2.254&r2=2.255
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16046
retrieving revision 1.16047
diff -u -b -r1.16046 -r1.16047
--- ChangeLog 29 Aug 2009 02:07:42 -0000 1.16046
+++ ChangeLog 29 Aug 2009 14:44:45 -0000 1.16047
@@ -1,5 +1,10 @@
2009-08-29 Stefan Monnier <address@hidden>
+ * emacs-lisp/bytecomp.el (byte-compile-const-symbol-p):
+ Recognize immutable variables like most-positive-fixnum.
+ (byte-compile-setq-default): Check and warn if trying to assign
+ to an immutable variable, or a non-variable.
+
* progmodes/cc-vars.el (c-comment-continuation-stars):
* progmodes/cc-engine.el (c-looking-at-bos):
* progmodes/cc-cmds.el (c-toggle-auto-state)
Index: emacs-lisp/bytecomp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.254
retrieving revision 2.255
diff -u -b -r2.254 -r2.255
--- emacs-lisp/bytecomp.el 28 Aug 2009 17:02:55 -0000 2.254
+++ emacs-lisp/bytecomp.el 29 Aug 2009 14:44:50 -0000 2.255
@@ -1506,7 +1506,14 @@
symbol itself."
(or (memq symbol '(nil t))
(keywordp symbol)
- (if any-value (memq symbol byte-compile-const-variables))))
+ (if any-value
+ (or (memq symbol byte-compile-const-variables)
+ ;; FIXME: We should provide a less intrusive way to find out
+ ;; is a variable is "constant".
+ (and (boundp symbol)
+ (condition-case nil
+ (progn (set symbol (symbol-value symbol)) nil)
+ (setting-constant t)))))))
(defmacro byte-compile-constp (form)
"Return non-nil if FORM is a constant."
@@ -3483,8 +3490,14 @@
(let ((args (cdr form))
setters)
(while args
- (setq setters
- (cons (list 'set-default (list 'quote (car args)) (car (cdr args)))
+ (let ((var (car args)))
+ (if (or (not (symbolp var))
+ (byte-compile-const-symbol-p var t))
+ (byte-compile-warn
+ "variable assignment to %s `%s'"
+ (if (symbolp var) "constant" "nonvariable")
+ (prin1-to-string var)))
+ (push (list 'set-default (list 'quote var) (car (cdr args)))
setters))
(setq args (cdr (cdr args))))
(byte-compile-form (cons 'progn (nreverse setters)))))