# HG changeset patch # User Aidan Kehoe # Date 1286710358 -3600 # Node ID dcc34e28cd84cda4cdd5bfc3b58aef06c0da78c2 # Parent aa20a889ff1421e5a884e09bd57bc7f16b7d82d5 Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp 2010-10-10 Aidan Kehoe * 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. diff -r aa20a889ff14 -r dcc34e28cd84 lisp/ChangeLog --- 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 + + * 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 * backquote.el (bq-vector-contents, bq-list*): Remove; the former diff -r aa20a889ff14 -r dcc34e28cd84 lisp/bytecomp.el --- 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)))