mysterious compile-time type error

Bug #908102 reported by Christophe Rhodes
8
This bug affects 1 person
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-pos-in-field))
(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
       (linear-pos-in-field (+ 2 *height*) (+ 1 *width*)))
    :element-type 'element-type
    :initial-element 0))

(defun shift-field (orig-f &optional (f (make-field)))
  (declare (type field-type orig-f f)))

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.