Function: comp-cstr-type-p
comp-cstr-type-p is a byte-compiled function defined in
comp-cstr.el.gz.
Signature
(comp-cstr-type-p CSTR TYPE)
Documentation
Return t if CSTR is certainly of type TYPE.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp-cstr.el.gz
(defun comp-cstr-type-p (cstr type)
"Return t if CSTR is certainly of type TYPE."
;; Only basic types are valid input.
(cl-assert (symbolp type))
(when
(with-comp-cstr-accessors
(cl-case type
(integer
(if (or (valset cstr) (neg cstr))
nil
(or (equal (typeset cstr) '(integer))
(and (range cstr)
(or (null (typeset cstr))
(equal (typeset cstr) '(integer)))))))
(t
(if-let* ((pred (get type 'cl-deftype-satisfies)))
(and (null (range cstr))
(null (neg cstr))
(if (null (typeset cstr))
(and (valset cstr)
(cl-every pred (valset cstr)))
(when (equal (typeset cstr) `(,type))
;; (valset cstr) can be nil as well.
(cl-every pred (valset cstr)))))
(error "Unknown predicate for type %s" type)))))
t))