diff options
author | Philipp Stephani <phst@google.com> | 2017-12-21 18:25:49 +0100 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2018-01-28 19:21:47 +0100 |
commit | 9a747b3554515135d5acadfcb5c2b1b8240d8f84 (patch) | |
tree | 3e1511ef5cbef7876e44a4f1ef4f2d7550e772db /test/lisp/emacs-lisp/cl-macs-tests.el | |
parent | a718e1593ae7332fafe734f880181e2d8ecc34df (diff) | |
download | emacs-9a747b3554515135d5acadfcb5c2b1b8240d8f84.tar.gz emacs-9a747b3554515135d5acadfcb5c2b1b8240d8f84.tar.bz2 emacs-9a747b3554515135d5acadfcb5c2b1b8240d8f84.zip |
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.
Diffstat (limited to 'test/lisp/emacs-lisp/cl-macs-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 10 |
1 files changed, 9 insertions, 1 deletions
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 |