diff options
| author | Mattias EngdegÄrd | 2021-09-23 12:43:41 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2021-09-25 20:25:01 +0200 |
| commit | ed02b88bbae18caad650d76876940ffb58cab554 (patch) | |
| tree | 36512b017e92a76a37c63606821274bd35366924 /test/src | |
| parent | 80fddff5d64ff915651eb751685b7430de00c536 (diff) | |
| download | emacs-ed02b88bbae18caad650d76876940ffb58cab554.tar.gz emacs-ed02b88bbae18caad650d76876940ffb58cab554.zip | |
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.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/eval-tests.el | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index b2b7dfefda5..3c3e7033419 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -39,31 +39,40 @@ | |||
| 39 | (ert-deftest eval-tests--bugs-24912-and-24913 () | 39 | (ert-deftest eval-tests--bugs-24912-and-24913 () |
| 40 | "Check that Emacs doesn't accept weird argument lists. | 40 | "Check that Emacs doesn't accept weird argument lists. |
| 41 | Bug#24912 and Bug#24913." | 41 | Bug#24912 and Bug#24913." |
| 42 | (dolist (args '((&rest &optional) | 42 | (dolist (lb '(t false)) |
| 43 | (&rest a &optional) (&rest &optional a) | 43 | (ert-info ((prin1-to-string lb) :prefix "lexical-binding: ") |
| 44 | (&optional &optional) (&optional &optional a) | 44 | (let ((lexical-binding lb)) |
| 45 | (&optional a &optional b) | 45 | (dolist (args '((&rest &optional) |
| 46 | (&rest &rest) (&rest &rest a) | 46 | (&rest a &optional) (&rest &optional a) |
| 47 | (&rest a &rest b))) | 47 | (&optional &optional) (&optional &optional a) |
| 48 | (should-error (eval `(funcall (lambda ,args)) t) :type 'invalid-function) | 48 | (&optional a &optional b) |
| 49 | (should-error (byte-compile-check-lambda-list args)) | 49 | (&rest &rest) (&rest &rest a) |
| 50 | (let ((byte-compile-debug t)) | 50 | (&rest a &rest b) |
| 51 | (ert-info ((format "bytecomp: args = %S" args)) | 51 | (&rest) (&optional &rest) |
| 52 | (should-error (eval `(byte-compile (lambda ,args)) t)))))) | 52 | )) |
| 53 | 53 | (ert-info ((prin1-to-string args) :prefix "args: ") | |
| 54 | (ert-deftest eval-tests-accept-empty-optional-rest () | 54 | (should-error |
| 55 | "Check that Emacs accepts empty &optional and &rest arglists. | 55 | (eval `(funcall (lambda ,args)) lb) :type 'invalid-function) |
| 56 | (should-error (byte-compile-check-lambda-list args)) | ||
| 57 | (let ((byte-compile-debug t)) | ||
| 58 | (should-error (eval `(byte-compile (lambda ,args)) lb))))))))) | ||
| 59 | |||
| 60 | (ert-deftest eval-tests-accept-empty-optional () | ||
| 61 | "Check that Emacs accepts empty &optional arglists. | ||
| 56 | Bug#24912." | 62 | Bug#24912." |
| 57 | (dolist (args '((&optional) (&rest) (&optional &rest) | 63 | (dolist (lb '(t false)) |
| 58 | (&optional &rest a) (&optional a &rest))) | 64 | (ert-info ((prin1-to-string lb) :prefix "lexical-binding: ") |
| 59 | (let ((fun `(lambda ,args 'ok))) | 65 | (let ((lexical-binding lb)) |
| 60 | (ert-info ("eval") | 66 | (dolist (args '((&optional) (&optional &rest a))) |
| 61 | (should (eq (funcall (eval fun t)) 'ok))) | 67 | (ert-info ((prin1-to-string args) :prefix "args: ") |
| 62 | (ert-info ("byte comp check") | 68 | (let ((fun `(lambda ,args 'ok))) |
| 63 | (byte-compile-check-lambda-list args)) | 69 | (ert-info ("eval") |
| 64 | (ert-info ("bytecomp") | 70 | (should (eq (funcall (eval fun lb)) 'ok))) |
| 65 | (let ((byte-compile-debug t)) | 71 | (ert-info ("byte comp check") |
| 66 | (should (eq (funcall (byte-compile fun)) 'ok))))))) | 72 | (byte-compile-check-lambda-list args)) |
| 73 | (ert-info ("bytecomp") | ||
| 74 | (let ((byte-compile-debug t)) | ||
| 75 | (should (eq (funcall (byte-compile fun)) 'ok))))))))))) | ||
| 67 | 76 | ||
| 68 | 77 | ||
| 69 | (dolist (form '(let let*)) | 78 | (dolist (form '(let let*)) |