diff 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
line wrap: on
line diff
--- a/lisp/bytecomp.el	Thu Sep 16 13:51:49 2010 +0100
+++ b/lisp/bytecomp.el	Thu Sep 16 14:10:44 2010 +0100
@@ -3581,10 +3581,13 @@
 ;; and (funcall (function foo)) will lose with autoloads.
 
 (defun byte-compile-function-form (form)
-  (byte-compile-constant
-   (cond ((symbolp (nth 1 form))
-	  (nth 1 form))
-	 ((byte-compile-lambda (nth 1 form))))))
+  (if (cddr form)
+      (byte-compile-normal-call
+       `(signal 'wrong-number-of-arguments '(function ,(length (cdr form)))))
+    (byte-compile-constant
+     (cond ((symbolp (nth 1 form))
+            (nth 1 form))
+           ((byte-compile-lambda (nth 1 form)))))))
 
 (defun byte-compile-insert (form)
   (cond ((null (cdr form))
@@ -3714,11 +3717,16 @@
 
 
 (defun byte-compile-quote (form)
-  (byte-compile-constant (car (cdr form))))
+  (if (cddr form)
+      (byte-compile-normal-call
+       `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form)))))
+    (byte-compile-constant (car (cdr form)))))
 
 (defun byte-compile-quote-form (form)
-  (byte-compile-constant (byte-compile-top-level (nth 1 form))))
-
+  (if (cddr form)
+      (byte-compile-normal-call
+       `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form)))))
+    (byte-compile-constant (byte-compile-top-level (nth 1 form)))))
 
 ;;; control structures