changeset 5282:dcc34e28cd84

Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are also constant. (byte-compile-initial-macro-environment): In #'the, if FORM is constant and does not match TYPE, warn at byte-compile time.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 10 Oct 2010 12:32:38 +0100
parents aa20a889ff14
children be436ac36ba4
files lisp/ChangeLog lisp/bytecomp.el
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Oct 10 12:13:32 2010 +0100
+++ b/lisp/ChangeLog	Sun Oct 10 12:32:38 2010 +0100
@@ -1,3 +1,10 @@
+2010-10-10  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are
+	also constant.
+	(byte-compile-initial-macro-environment): In #'the, if FORM is
+	constant and does not match TYPE, warn at byte-compile time.
+
 2010-10-10  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* backquote.el (bq-vector-contents, bq-list*): Remove; the former
--- a/lisp/bytecomp.el	Sun Oct 10 12:13:32 2010 +0100
+++ b/lisp/bytecomp.el	Sun Oct 10 12:32:38 2010 +0100
@@ -505,6 +505,10 @@
 	     (cons 'progn body)))
     (the .
       ,#'(lambda (type form)
+	   (if (cl-const-expr-p form)
+	       (or (eval (cl-make-type-test form type))
+		   (byte-compile-warn
+		    "%s is not of type %s" form type)))
 	   (if byte-compile-delete-errors
 	       form
 	     (funcall (cdr (symbol-function 'the)) type form)))))
@@ -1391,7 +1395,7 @@
 
 (defmacro byte-compile-constp (form)
   ;; Returns non-nil if FORM is a constant.
-  `(cond ((consp ,form) (eq (car ,form) 'quote))
+  `(cond ((consp ,form) (memq (car ,form) '(quote function)))
 	 ((symbolp ,form) (byte-compile-constant-symbol-p ,form))
 	 (t)))