From 592a2cca1762e7f4008f3ebbb11d8d02267abcb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Tue, 11 Jul 2023 16:35:17 +0200 Subject: [PATCH] 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)) --- src/cmp/cmpopt.lsp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cmp/cmpopt.lsp b/src/cmp/cmpopt.lsp index a3b66d992..edcc46298 100644 --- a/src/cmp/cmpopt.lsp +++ b/src/cmp/cmpopt.lsp @@ -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)