Commit 3e96dd4f authored by Stefan Monnier's avatar Stefan Monnier
Browse files

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.
parent 0cc44094
Pipeline #28481 failed with stages
in 113 minutes and 15 seconds
......@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment