mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 08:43:40 -07:00
Renege on anonymous &rest (bug#50268, bug#50720)
Allowing &rest without a variable name following turned out not to be very useful, and it never worked properly. Disallow it. * lisp/emacs-lisp/bytecomp.el (byte-compile-check-lambda-list): * src/eval.c (funcall_lambda): Signal error for &rest without variable name. * doc/lispref/functions.texi (Argument List): Adjust manual. * etc/NEWS (file): Announce. * test/src/eval-tests.el (eval-tests--bugs-24912-and-24913): Extend test, also checking with and without lexical binding. (eval-tests-accept-empty-optional-rest): Reduce to... (eval-tests-accept-empty-optional): ...this, again checking with and without lexical binding.
This commit is contained in:
parent
80fddff5d6
commit
ed02b88bba
5 changed files with 48 additions and 27 deletions
|
|
@ -39,31 +39,40 @@
|
|||
(ert-deftest eval-tests--bugs-24912-and-24913 ()
|
||||
"Check that Emacs doesn't accept weird argument lists.
|
||||
Bug#24912 and Bug#24913."
|
||||
(dolist (args '((&rest &optional)
|
||||
(&rest a &optional) (&rest &optional a)
|
||||
(&optional &optional) (&optional &optional a)
|
||||
(&optional a &optional b)
|
||||
(&rest &rest) (&rest &rest a)
|
||||
(&rest a &rest b)))
|
||||
(should-error (eval `(funcall (lambda ,args)) t) :type 'invalid-function)
|
||||
(should-error (byte-compile-check-lambda-list args))
|
||||
(let ((byte-compile-debug t))
|
||||
(ert-info ((format "bytecomp: args = %S" args))
|
||||
(should-error (eval `(byte-compile (lambda ,args)) t))))))
|
||||
(dolist (lb '(t false))
|
||||
(ert-info ((prin1-to-string lb) :prefix "lexical-binding: ")
|
||||
(let ((lexical-binding lb))
|
||||
(dolist (args '((&rest &optional)
|
||||
(&rest a &optional) (&rest &optional a)
|
||||
(&optional &optional) (&optional &optional a)
|
||||
(&optional a &optional b)
|
||||
(&rest &rest) (&rest &rest a)
|
||||
(&rest a &rest b)
|
||||
(&rest) (&optional &rest)
|
||||
))
|
||||
(ert-info ((prin1-to-string args) :prefix "args: ")
|
||||
(should-error
|
||||
(eval `(funcall (lambda ,args)) lb) :type 'invalid-function)
|
||||
(should-error (byte-compile-check-lambda-list args))
|
||||
(let ((byte-compile-debug t))
|
||||
(should-error (eval `(byte-compile (lambda ,args)) lb)))))))))
|
||||
|
||||
(ert-deftest eval-tests-accept-empty-optional-rest ()
|
||||
"Check that Emacs accepts empty &optional and &rest arglists.
|
||||
(ert-deftest eval-tests-accept-empty-optional ()
|
||||
"Check that Emacs accepts empty &optional arglists.
|
||||
Bug#24912."
|
||||
(dolist (args '((&optional) (&rest) (&optional &rest)
|
||||
(&optional &rest a) (&optional a &rest)))
|
||||
(let ((fun `(lambda ,args 'ok)))
|
||||
(ert-info ("eval")
|
||||
(should (eq (funcall (eval fun t)) 'ok)))
|
||||
(ert-info ("byte comp check")
|
||||
(byte-compile-check-lambda-list args))
|
||||
(ert-info ("bytecomp")
|
||||
(let ((byte-compile-debug t))
|
||||
(should (eq (funcall (byte-compile fun)) 'ok)))))))
|
||||
(dolist (lb '(t false))
|
||||
(ert-info ((prin1-to-string lb) :prefix "lexical-binding: ")
|
||||
(let ((lexical-binding lb))
|
||||
(dolist (args '((&optional) (&optional &rest a)))
|
||||
(ert-info ((prin1-to-string args) :prefix "args: ")
|
||||
(let ((fun `(lambda ,args 'ok)))
|
||||
(ert-info ("eval")
|
||||
(should (eq (funcall (eval fun lb)) 'ok)))
|
||||
(ert-info ("byte comp check")
|
||||
(byte-compile-check-lambda-list args))
|
||||
(ert-info ("bytecomp")
|
||||
(let ((byte-compile-debug t))
|
||||
(should (eq (funcall (byte-compile fun)) 'ok)))))))))))
|
||||
|
||||
|
||||
(dolist (form '(let let*))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue