From 83ed2e172273ab2dad9eb90d0f31027341eda644 Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Sun, 21 Mar 2021 17:21:17 +0100 Subject: [PATCH] cmp: checked-value: don't omit type checks if we detect a type-error at compile time We now warn at compile time and create a type assertion which errors at runtime. --- src/cmp/cmptype-assert.lsp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cmp/cmptype-assert.lsp b/src/cmp/cmptype-assert.lsp index fa7fd726f..8675accd2 100644 --- a/src/cmp/cmptype-assert.lsp +++ b/src/cmp/cmptype-assert.lsp @@ -119,20 +119,20 @@ and-type (type-and form-type type)) (eq and-type form-type)) form) - ;; Are the form type and the test disjoint types? - ((null and-type) - (cmpwarn "The expression ~S is not of the expected type ~S" - value type) - form) ;; Otherwise, emit a full test (t - (cmpdebug "Checking type of ~S to be ~S" value type) + (if (null and-type) ; Are the form type and the test disjoint types? + (cmpwarn "The expression ~S is not of the expected type ~S" + value type) + (cmpdebug "Checking type of ~S to be ~S" value type)) (let ((full-check (with-clean-symbols (%checked-value) `(let* ((%checked-value ,value)) (declare (:read-only %checked-value)) ,(expand-type-assertion '%checked-value type *cmp-env* nil) - (truly-the ,type %checked-value))))) + ,(if (null and-type) + '%checked-value + `(truly-the ,type %checked-value)))))) (make-c1form* 'CHECKED-VALUE :type type :args type form (c1expr full-check)))))))