See example in t/invalid-branch-playground.lisp.
Function invalid-branch
&optional message
This function mark a specific part of the code to be invalid. It MUST NOT be used in a valid code.
- On unsupported implementations, this function has no compile-time effect and just signals an error in runtime.
- On supported implementations (currently SBCL only), the compiler signals a warning,style-warning or error (depending on the value of
*INVALID-BRANCH-WARNING-LEVEL*
) when the compiler fails to eliminiate it as a dead-code.
This is useful to detect a specific kind of errors,
e.g. type errors, infinite loops, infinite recursion and so on.
When it happens, you should fix the code, add a type restriction etc.
in order to make it compile.
For example, using invalid-branch
in a default method of inlined-generic-function, you can perform a static type checking (only on sbcl).
Supported implementations: You can check these test results on Travis-CI.
- SBCL
- This feature is tested against all most recent patch versions in the past three minor versions. That is, 1.3.9, 1.2.16, 1.1.18.
Special Variable *invalid-branch-warning-level*
(declaim (type (member alexandria:simple-style-warning warn error) *invalid-branch-warning-level*))
A flag controlling the level of compile-time warning signaled when compiling a call to INVALID-BRANCH. This does not affect the runtime behavior of INVALID-BRANCH, which always signals an error.
The default value is warning
.