]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/bytecomp.el
Byte compiler: on setq with an odd number of arguments, generate a `signal'
[gnu-emacs] / lisp / emacs-lisp / bytecomp.el
index 58cce67598c4082b0672f824145a9b76e72751c3..ffe73defcbb4683ddefb2ad3570be8487629cd7d 100644 (file)
@@ -3741,20 +3741,24 @@ discarding."
 (byte-defop-compiler-1 quote)
 
 (defun byte-compile-setq (form)
-  (let ((args (cdr form)))
-    (if args
-       (while args
-         (if (eq (length args) 1)
-              (byte-compile-log-warning
-               (format "missing value for `%S' at end of setq" (car args))
-               nil :error))
-          (byte-compile-form (car (cdr args)))
-         (or byte-compile--for-effect (cdr (cdr args))
-             (byte-compile-out 'byte-dup 0))
-         (byte-compile-variable-set (car args))
-         (setq args (cdr (cdr args))))
-      ;; (setq), with no arguments.
-      (byte-compile-form nil byte-compile--for-effect))
+  (let* ((args (cdr form))
+         (len (length args)))
+    (if (= (logand len 1) 1)
+        (progn
+          (byte-compile-log-warning
+           (format "missing value for `%S' at end of setq" (car (last args)))
+           nil :error)
+          (byte-compile-form
+           `(signal 'wrong-number-of-arguments '(setq ,len))))
+      (if args
+          (while args
+            (byte-compile-form (car (cdr args)))
+            (or byte-compile--for-effect (cdr (cdr args))
+                (byte-compile-out 'byte-dup 0))
+            (byte-compile-variable-set (car args))
+            (setq args (cdr (cdr args))))
+        ;; (setq), with no arguments.
+        (byte-compile-form nil byte-compile--for-effect)))
     (setq byte-compile--for-effect nil)))
 
 (defun byte-compile-setq-default (form)