I imagine that something like this would work:
(defconstant +len+ 3)
(deftype len-3-fixnum-array () `(array fixnum (,+len+)))
(defun foo (x)
(declare (type len-3-fixnum-array x))
(print x))
(foo (make-array 3 :element-type 'fixnum))
;; #(0 0 0)
(foo (make-array 4 :element-type 'fixnum))
;; The value #(0 0 0 0) is not of type (VECTOR FIXNUM 3).
;; [Condition of type TYPE-ERROR]
However, you need to keep in mind that type annotations are only recommendations, compilers are allowed to ignore them altogether.
I.e. the problem isn't that you can't use constants in the declare
form, it's that it acts as if it was quoted, so your constant there doesn't evaluate to 3, it just stays the symbol +len+
.