]> git.eshelyaron.com Git - emacs.git/commitdiff
Check that variable lists are actually lists
authorPhilipp Stephani <phst@google.com>
Wed, 18 Jan 2017 18:49:58 +0000 (19:49 +0100)
committerPhilipp Stephani <phst@google.com>
Thu, 19 Jan 2017 16:17:50 +0000 (17:17 +0100)
'let' and 'let*' document that their first argument has to be a list,
but don't check for that; instead, they allow (and silently ignore)
other types.  Introduce an explicit type check.

* src/eval.c (Flet, FletX): Check that the variable list is indeed a
list.
* test/src/eval-tests.el: Add unit tests.

src/eval.c
test/src/eval-tests.el

index 1f8d40993246e7ec90b6f6150a4f6ca470186a0d..c05c8d8f8de88d8238a097eead46945a324610a2 100644 (file)
@@ -857,6 +857,7 @@ usage: (let* VARLIST BODY...)  */)
   lexenv = Vinternal_interpreter_environment;
 
   varlist = XCAR (args);
+  CHECK_LIST (varlist);
   while (CONSP (varlist))
     {
       QUIT;
@@ -917,6 +918,7 @@ usage: (let VARLIST BODY...)  */)
   USE_SAFE_ALLOCA;
 
   varlist = XCAR (args);
+  CHECK_LIST (varlist);
 
   /* Make space to hold the values to give the bound variables.  */
   elt = Flength (varlist);
index a1fe8ccd7d901074905c21889344b310885d1922..95655eac826a87a3bd51e00f16a5cdc2e23f8769 100644 (file)
@@ -47,4 +47,14 @@ Bug#24912 and Bug#24913."
     (let ((byte-compile-debug t))
       (should-error (eval `(byte-compile (lambda ,args)) t)))))
 
+
+(dolist (form '(let let*))
+  (dolist (arg '(1 "a" [a]))
+    (eval
+     `(ert-deftest ,(intern (format "eval-tests--%s--%s" form (type-of arg))) ()
+        ,(format "Check that the first argument of `%s' cannot be a %s"
+                 form (type-of arg))
+        (should-error (,form ,arg) :type 'wrong-type-argument))
+     t)))
+
 ;;; eval-tests.el ends here