mysterious compile-time type error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
affects sbcl
done
The below code generates a compile-time type error in the compilation of
SHIFT-FIELD, but I can't for the life of me see why. It is true that
the compiler is clever enough to spot that the call to
LINEAR-POS-IN-FIELD never returns (the asserts are the wrong way round)
but that should /help/, because MAKE-FIELD is then known to be a
(FUNCTION NIL NIL). Baffled.
(declaim (optimize (debug 3) (safety 3)))
(deftype element-type () '(unsigned-byte 8))
(deftype field-type () '(array element-type *))
(defparameter *width* 0)
(defparameter *height* 0)
(deftype coord-type () '(integer -1 100))
(declaim (type coord-type *width* *height*))
(declaim (inline linear-
(defun linear-pos-in-field (x y)
;(declare (type coord-type x y))
(assert (>= 0 x))
(assert (>= 0 y))
(assert (< x *width*))
(assert (< y *height*))
(+ (* (1+ y) *width*)
(1+ x)))
(defun make-field ()
;; we make an array that's "big" enough.
;; The right and left borders are the same elements.
(make-array
(+ 1 ;; +1 is the top-left-most element
:element-type 'element-type
:initial-
(defun shift-field (orig-f &optional (f (make-field)))
(declare (type field-type orig-f f)))