Mercurial > hg > xemacs-beta
comparison lisp/bytecomp.el @ 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 | 90a0084b3541 |
children | bbff29a01820 |
comparison
equal
deleted
inserted
replaced
5281:aa20a889ff14 | 5282:dcc34e28cd84 |
---|---|
503 . ,#'(lambda (&rest body) | 503 . ,#'(lambda (&rest body) |
504 (byte-compile-eval (cons 'progn body)) | 504 (byte-compile-eval (cons 'progn body)) |
505 (cons 'progn body))) | 505 (cons 'progn body))) |
506 (the . | 506 (the . |
507 ,#'(lambda (type form) | 507 ,#'(lambda (type form) |
508 (if (cl-const-expr-p form) | |
509 (or (eval (cl-make-type-test form type)) | |
510 (byte-compile-warn | |
511 "%s is not of type %s" form type))) | |
508 (if byte-compile-delete-errors | 512 (if byte-compile-delete-errors |
509 form | 513 form |
510 (funcall (cdr (symbol-function 'the)) type form))))) | 514 (funcall (cdr (symbol-function 'the)) type form))))) |
511 "The default macro-environment passed to macroexpand by the compiler. | 515 "The default macro-environment passed to macroexpand by the compiler. |
512 Placing a macro here will cause a macro to have different semantics when | 516 Placing a macro here will cause a macro to have different semantics when |
1389 (defmacro byte-compile-constant-symbol-p (symbol) | 1393 (defmacro byte-compile-constant-symbol-p (symbol) |
1390 `(or (keywordp ,symbol) (memq ,symbol '(nil t)))) | 1394 `(or (keywordp ,symbol) (memq ,symbol '(nil t)))) |
1391 | 1395 |
1392 (defmacro byte-compile-constp (form) | 1396 (defmacro byte-compile-constp (form) |
1393 ;; Returns non-nil if FORM is a constant. | 1397 ;; Returns non-nil if FORM is a constant. |
1394 `(cond ((consp ,form) (eq (car ,form) 'quote)) | 1398 `(cond ((consp ,form) (memq (car ,form) '(quote function))) |
1395 ((symbolp ,form) (byte-compile-constant-symbol-p ,form)) | 1399 ((symbolp ,form) (byte-compile-constant-symbol-p ,form)) |
1396 (t))) | 1400 (t))) |
1397 | 1401 |
1398 (defmacro byte-compile-close-variables (&rest body) | 1402 (defmacro byte-compile-close-variables (&rest body) |
1399 `(let | 1403 `(let |