Loop destructuring default values and declarations
By Eric Marsden on sbcl-devel@
CLtS 126.96.36.199 says that "If the optional type-spec argument is supplied
for the variable var, but there is no related expression to be
evaluated, var is initialized to an appropriate default value for its
type. For example, for the types t, number, and float, the default
values are nil, 0, and 0.0 respectively.".
It seems to me that in the example below (from the spec BTW, even if
examples are not normative), the compiler is raising a spurious error
concerning a LOOP-IGNORE-XX variable.
* (loop with (a b c) of-type float return (format nil "~A ~A ~A" a b c))
; in: LOOP WITH
; (LET ((A 0.0) (B 0.0) (C 0.0) (#:LOOP-IGNORE-609 NIL))
; (DECLARE (TYPE FLOAT #:LOOP-IGNORE-609)
; (IGNORE #:LOOP-IGNORE-609)
; (TYPE FLOAT C)
; (TYPE FLOAT B)
; (TYPE FLOAT A))
; (SB-LOOP::LOOP-BODY NIL NIL
; ((RETURN-FROM NIL (FORMAT NIL "~A ~A ~A" A B C))) NIL
; caught WARNING:
; Constant NIL conflicts with its asserted type FLOAT.