aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2017-11-13 12:46:13 -0500
committerNoam Postavsky2017-12-13 17:31:27 -0500
commite7b1111155b3116d0c7b137e0e1d312db0f1ca80 (patch)
tree30240245d971e634ed1ec0f60733fe6dde2e1421 /test
parent4cb8696e4754d815efd5fd5e26f2b6b2567a11fe (diff)
downloademacs-e7b1111155b3116d0c7b137e0e1d312db0f1ca80.tar.gz
emacs-e7b1111155b3116d0c7b137e0e1d312db0f1ca80.zip
Mention new strictness for &optional, &rest in arglists (Bug#29165)
* etc/NEWS: Explain that '&optional' not followed by a variable is now an error. * lisp/emacs-lisp/cl-macs.el (cl--transform-lambda, cl--do-&aux) (cl--do-arglist): Also reject '&optional', '&rest', or '&aux' not followed by a variable for consistency. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-bad-arglist): New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/cl-macs-tests.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el
index 575f170af6c..bf2e7e12759 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -497,4 +497,35 @@ collection clause."
497 vconcat (vector (1+ x))) 497 vconcat (vector (1+ x)))
498 [2 3 4 5 6]))) 498 [2 3 4 5 6])))
499 499
500
501;;; cl-lib lambda list handling
502
503(ert-deftest cl-macs-bad-arglist ()
504 "Check that `cl-defun' and friends reject weird argument lists.
505See Bug#29165, and similar `eval-tests--bugs-24912-and-24913' in
506eval-tests.el."
507 (dolist (args (cl-mapcan
508 ;; For every &rest and &optional variant, check also
509 ;; the same thing with &key and &aux respectively
510 ;; instead.
511 (lambda (arglist)
512 (let ((arglists (list arglist)))
513 (when (memq '&rest arglist)
514 (push (cl-subst '&key '&rest arglist) arglists))
515 (when (memq '&optional arglist)
516 (push (cl-subst '&aux '&optional arglist) arglists))
517 arglists))
518 '((&optional) (&rest) (&optional &rest) (&rest &optional)
519 (&optional &rest _a) (&optional _a &rest)
520 (&rest _a &optional) (&rest &optional _a)
521 (&optional &optional) (&optional &optional _a)
522 (&optional _a &optional _b)
523 (&rest &rest) (&rest &rest _a)
524 (&rest _a &rest _b))))
525 (ert-info ((prin1-to-string args) :prefix "arglist: ")
526 (should-error (eval `(funcall (cl-function (lambda ,args))) t))
527 (should-error (cl--transform-lambda (cons args t)))
528 (let ((byte-compile-debug t))
529 (should-error (eval `(byte-compile (cl-function (lambda ,args))) t))))))
530
500;;; cl-macs-tests.el ends here 531;;; cl-macs-tests.el ends here