Type problem when optimizing
The following code snipped gives the following error: ;;;*** Warning in %SET-CREATURE-Y-POSITION: Declared type (DOUBLE-FLOAT * *) and value type FIXNUM are disjoint. The warning goes away if I remove the "(the float" down at the bottom but the code bombs trying to put together mismatched types under high optimization. I can't figure out why it considers either (aref location 1) or (terrain-vertex ...) to be a fixnum. If I put in a (declare (ftype (function (fixnum fixnum) double-float) terrain-vertex) after the terrain-vertex definition it will give the same message, seeming to indicate it is expecting terrain-vertex to return a fixnum. I have verified that name/symbol terrain-vertex does not appear anywhere else in the code and might be causing a conflict. Any thoughts? Thanks, brad (defun %set-creature-y-position (creature terrain) (declare (optimize (speed 3)(safety 2)(hcl:fixnum-safety 2))) (let ((location (location creature)) (vertices (vertices terrain))) (declare (type (simple-array double-float (3)) location) (type (simple-array single-float (*)) vertices)) (flet ((terrain-vertex (x-pos z-pos) (declare (type fixnum x-pos z-pos)) (let* ((width (width terrain)) (adjust (the fixnum (/ (1- width) 2))) (x (+ x-pos adjust)) (z (+ z-pos adjust))) (declare (type fixnum width x z)) (let* ((sw-index (* 3 (+ x (* z width)))) (ne-index (+ sw-index (* 3 (1+ width)))) (sw-Y-value (aref vertices (1+ sw-index))) (ne-Y-value (aref vertices (1+ ne-index)))) (+ 0.1 (max sw-Y-value ne-Y-value)))))) (setf (aref location 1) (the float (terrain-vertex (floor (aref location 0))(floor (aref location 2))))))))