comparison lisp/bytecomp.el @ 5265:5663ae9a8989

Warn at compile time, error at runtime, with (quote X Y), (function X Y). lisp/ChangeLog addition: 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-function-form, byte-compile-quote) (byte-compile-quote-form): Warn at compile time, and error at runtime, if a (quote ...) or a (function ...) form attempts to quote more than one object. src/ChangeLog addition: 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * eval.c (Ffunction, Fquote): Add argument information in the arguments: () format for these two special operators.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 16 Sep 2010 14:10:44 +0100
parents 0d436a78c514
children 90a0084b3541
comparison
equal deleted inserted replaced
5264:0d43872986b6 5265:5663ae9a8989
3579 ;; (function foo) must compile like 'foo, not like (symbol-function 'foo). 3579 ;; (function foo) must compile like 'foo, not like (symbol-function 'foo).
3580 ;; Otherwise it will be incompatible with the interpreter, 3580 ;; Otherwise it will be incompatible with the interpreter,
3581 ;; and (funcall (function foo)) will lose with autoloads. 3581 ;; and (funcall (function foo)) will lose with autoloads.
3582 3582
3583 (defun byte-compile-function-form (form) 3583 (defun byte-compile-function-form (form)
3584 (byte-compile-constant 3584 (if (cddr form)
3585 (cond ((symbolp (nth 1 form)) 3585 (byte-compile-normal-call
3586 (nth 1 form)) 3586 `(signal 'wrong-number-of-arguments '(function ,(length (cdr form)))))
3587 ((byte-compile-lambda (nth 1 form)))))) 3587 (byte-compile-constant
3588 (cond ((symbolp (nth 1 form))
3589 (nth 1 form))
3590 ((byte-compile-lambda (nth 1 form)))))))
3588 3591
3589 (defun byte-compile-insert (form) 3592 (defun byte-compile-insert (form)
3590 (cond ((null (cdr form)) 3593 (cond ((null (cdr form))
3591 (byte-compile-constant nil)) 3594 (byte-compile-constant nil))
3592 ((<= (length form) 256) 3595 ((<= (length form) 256)
3712 (byte-compile-normal-call form) 3715 (byte-compile-normal-call form)
3713 (byte-compile-subr-wrong-args form 2)))) 3716 (byte-compile-subr-wrong-args form 2))))
3714 3717
3715 3718
3716 (defun byte-compile-quote (form) 3719 (defun byte-compile-quote (form)
3717 (byte-compile-constant (car (cdr form)))) 3720 (if (cddr form)
3721 (byte-compile-normal-call
3722 `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form)))))
3723 (byte-compile-constant (car (cdr form)))))
3718 3724
3719 (defun byte-compile-quote-form (form) 3725 (defun byte-compile-quote-form (form)
3720 (byte-compile-constant (byte-compile-top-level (nth 1 form)))) 3726 (if (cddr form)
3721 3727 (byte-compile-normal-call
3728 `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form)))))
3729 (byte-compile-constant (byte-compile-top-level (nth 1 form)))))
3722 3730
3723 ;;; control structures 3731 ;;; control structures
3724 3732
3725 (defun byte-compile-body (body &optional for-effect) 3733 (defun byte-compile-body (body &optional for-effect)
3726 (while (cdr body) 3734 (while (cdr body)