From 9a747b3554515135d5acadfcb5c2b1b8240d8f84 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Thu, 21 Dec 2017 18:25:49 +0100 Subject: Prevent name clashes between CL structures and builtin types * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Don't allow structures with the same names as builtin types. (cl--typeof-types, cl--all-builtin-types): Move from cl-generic.el and rename. (cl--struct-name-p): New helper function. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Don't allow structures with the same names as builtin types. * lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-generalizer) (cl-generic-generalizers): Adapt to name change. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/builtin-type): * test/lisp/emacs-lisp/cl-preloaded-tests.el (cl-struct-define/builtin-type): New unit tests. * etc/NEWS: Document changed behavior. --- test/lisp/emacs-lisp/cl-macs-tests.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/lisp/emacs-lisp/cl-macs-tests.el') diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index edb1530cad5..6e9fb44b4b0 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -497,7 +497,6 @@ collection clause." vconcat (vector (1+ x))) [2 3 4 5 6]))) - (ert-deftest cl-macs-loop-for-as-equals-and () "Test for https://debbugs.gnu.org/29799 ." (let ((arr (make-vector 3 0))) @@ -505,4 +504,13 @@ collection clause." (cl-loop for k below 3 for x = k and z = (elt arr k) collect (list k x)))))) + +(ert-deftest cl-defstruct/builtin-type () + (should-error + (macroexpand '(cl-defstruct hash-table)) + :type 'wrong-type-argument) + (should-error + (macroexpand '(cl-defstruct (hash-table (:predicate hash-table-p)))) + :type 'wrong-type-argument)) + ;;; cl-macs-tests.el ends here -- cgit v1.2.3