The SBCL compiler treats type declarations differently from most other Lisp compilers. Under default compilation policy the compiler doesn't blindly believe type declarations, but considers them assertions about the program that should be checked: all type declarations that have not been proven to always hold are asserted at runtime.
Remaining bugs in the compiler's handling of types unfortunately provide some exceptions to this rule, see Implementation Limitations).
There are three type checking policies available in SBCL,
selectable via optimize
declarations.
Used when (or (>= safety 2) (>= safety speed 1))
.
(and unsigned-byte fixnum)
is simplified into fixnum
.
Note: it is relatively easy to corrupt the heap when weak type checks are used if the program contains type-errors.
Used when (and (< safety 2) (< safety speed))
Note: any type errors in code where type checks are not performed are liable to corrupt the heap.
Used when (= safety 0)
.