Skip to content

Commit

Permalink
Shadow CL:CHECK-TYPE.
Browse files Browse the repository at this point in the history
I was using `check-type` because it was a handy shorthand, but it
turns out to mess up SBCL's type checking, because it's got a restart
where the user can reset the checked place.

Instead, replace with a macro that just checks the type and raises a
type error if the object is not correctly typed.
  • Loading branch information
rpgoldman committed Aug 2, 2024
1 parent 00a9613 commit ad5f7bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions shop3/decls.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,12 @@ task keyword of TASK and LIBRARY-TASK are the same.")
(member thing '(&optional &rest) :test #'eq)))
(if (find-if #'rest-or-optional-p types) `(values ,@types)
`(values ,@types &optional))))

;;;---------------------------------------------------------------------------
;;; CL:CHECK-TYPE messes up SBCL's type checking, because on continuation
;;; it allows the user to supply an object of a new type. Change it to just
;;; raise a type error. [2024/08/02:rpg]
;;;---------------------------------------------------------------------------
(defmacro check-type (place type)
`(unless (typep ,place ',type)
(error 'type-error :datum ,place :expected-type ',type)))
2 changes: 2 additions & 0 deletions shop3/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
(:documentation "The SHOP3 package is the package that exposes SHOP3's API.")
(:use :common-lisp :shop3.unifier :shop3.common :shop3.theorem-prover
:iterate)
;; override this...
(:shadow #:check-type)
(:import-from #:shop3.common #:domain-core)
(:import-from #:shop3.theorem-prover #:+numerical-comparisons+
#:fluent-value
Expand Down

0 comments on commit ad5f7bf

Please sign in to comment.