cmp: expand-typep: fix broken (complex type) expansion

This expansion did not account for the object not being a number. In that case
REALPART errored in the compiled code. Example:

    (typep *package* '(complex float))
This commit is contained in:
Daniel Kochmański 2023-07-11 16:35:17 +02:00
parent 4ec4187427
commit 592a2cca17

View file

@ -87,9 +87,9 @@
type
(first type))
'SI::DEFTYPE-DEFINITION))
(expand-typep form object `',(funcall function (if (atom type)
nil
(rest type)))
(expand-typep form object `(quote ,(funcall function (if (atom type)
nil
(rest type))))
env))
;;
;; There exists a function which checks for this type?
@ -162,7 +162,8 @@
;; Compound COMPLEX types.
((and (eq first 'COMPLEX)
(= (list-length type) 2))
`(and (typep (realpart ,object) ',(second type))
`(and (complexp ,object)
(typep (realpart ,object) ',(second type))
(typep (imagpart ,object) ',(second type))))
;;
;; (SATISFIES predicate)