summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/cl-macs-tests.el
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2017-12-21 18:25:49 +0100
committerPhilipp Stephani <phst@google.com>2018-01-28 19:21:47 +0100
commit9a747b3554515135d5acadfcb5c2b1b8240d8f84 (patch)
tree3e1511ef5cbef7876e44a4f1ef4f2d7550e772db /test/lisp/emacs-lisp/cl-macs-tests.el
parenta718e1593ae7332fafe734f880181e2d8ecc34df (diff)
downloademacs-9a747b3554515135d5acadfcb5c2b1b8240d8f84.tar.gz
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.el10
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