diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2024-03-12 12:00:17 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2024-03-12 12:00:17 -0400 |
commit | 3e96dd4f8851a45c66ebc9b8666ae449cc4c2725 (patch) | |
tree | bc6a44a2ecf27bfaccb35189c92dda8d46ed5cd9 /lisp/emacs-lisp | |
parent | 0cc44094613530744d3650e4a169335374d6727b (diff) | |
download | emacs-3e96dd4f8851a45c66ebc9b8666ae449cc4c2725.tar.gz emacs-3e96dd4f8851a45c66ebc9b8666ae449cc4c2725.tar.bz2 emacs-3e96dd4f8851a45c66ebc9b8666ae449cc4c2725.zip |
cl-generic: Signal an error when a type specializer won't work
* lisp/emacs-lisp/cl-generic.el (cl--generic--unreachable-types): New var.
(cl-generic-generalizers :extra "typeof"): Use it to signal an
error for those types we can't handle.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/cl-generic.el | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 84eb800ec24..613ecf82a92 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -1332,6 +1332,12 @@ These match if the argument is `eql' to VAL." ;;; Dispatch on "normal types". +(defconst cl--generic--unreachable-types + ;; FIXME: Try to make that list empty? + '(fixnum bignum boolean keyword + special-form subr-primitive subr-native-elisp) + "Built-in classes on which we cannot dispatch for technical reasons.") + (defun cl--generic-type-specializers (tag &rest _) (and (symbolp tag) (let ((class (cl--find-class tag))) @@ -1352,6 +1358,8 @@ This currently works for built-in types and types built on top of records." (and (symbolp type) (not (eq type t)) ;; Handled by the `t-generalizer'. (let ((class (cl--find-class type))) + (when (memq type cl--generic--unreachable-types) + (error "Dispatch on %S is currently not supported" type)) (memq (type-of class) '(built-in-class cl-structure-class eieio--class))) (list cl--generic-typeof-generalizer)) |