[iterate-devel] Error in array dimension declaration

Milan Jovanovic milanj at gmail.com
Thu Oct 15 16:54:59 UTC 2009


For example:

ITER> (let ((a (make-array 5 :element-type '(unsigned-byte 8))))
	(iter (repeat 1)
	      (for a2 = a)
	      (declare (type (simple-array (unsigned-byte 8) (8)) a2))
	      (print a2)))
; in: LAMBDA NIL
;     (ITERATE:ITER (ITERATE:REPEAT 1) (ITERATE:FOR ITERATE::A2 =  
ITERATE::A)
;                   (DECLARE
;                    (TYPE (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (8))  
ITERATE::A2))
;                   (PRINT ITERATE::A2))
;
; caught ERROR:
;   (in macroexpansion of (ITER (REPEAT 1) (FOR A2 = ...) ...))
;   (hint: For more precise location, try *BREAK-ON-SIGNALS*.)
;   The length requested (0) does not match the type restriction in  
(SIMPLE-ARRAY
;                                                                     
(UNSIGNED-BYTE
;                                                                     8)
;                                                                     
(8)).

;     (LET ((ITERATE::A (MAKE-ARRAY 5 :ELEMENT-TYPE '(UNSIGNED-BYTE  
8))))
;       (ITERATE:ITER (ITERATE:REPEAT 1) (ITERATE:FOR ITERATE::A2 =  
ITERATE::A)
;                     (DECLARE (TYPE (SIMPLE-ARRAY # #) ITERATE::A2))
;                     (PRINT ITERATE::A2)))
;
; caught STYLE-WARNING:
;   The variable A is defined but never used.
;
; compilation unit finished
;   caught 1 ERROR condition
;   caught 1 STYLE-WARNING condition
; Evaluation aborted.

This works :

ITER> (let ((a (make-array 5 :element-type '(unsigned-byte 8))))
	(iter (repeat 1)
	      (for a2 = a)
	      (declare (type (simple-array (unsigned-byte 8) (*)) a2))
	      (print a2)))

#(0 0 0 0 0)
NIL
ITER>


This is previous form expanded, looks like because of taking care for  
type inference it's making a array with dimension 0 with declaration  
that has specified dimension

(LET* ((#:COUNT154 NIL) (A2 #()))
  (DECLARE (TYPE (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) A2))
  (BLOCK NIL
    (TAGBODY
      (SETQ #:COUNT154 1)
     LOOP-TOP-NIL
      (IF (<= #:COUNT154 0) (GO LOOP-END-NIL))
      (SETQ A2 A)
      (PRINT A2)
      (SETQ #:COUNT154 (1- #:COUNT154))
      (GO LOOP-TOP-NIL)
     LOOP-END-NIL)
    NIL))

Thanks, Milan





More information about the iterate-devel mailing list