Steel Bank Common Lisp

Loop destructuring default values and declarations

Reported by Stas Boukarev on 2013-06-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

By Eric Marsden on sbcl-devel@
CLtS 6.1.2.2 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.

* (lisp-implementation-version)
"1.1.8.49-ded09c0-dirty"
* (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
; NIL))
;
; caught WARNING:
; Constant NIL conflicts with its asserted type FLOAT.

(From sacla-tests)

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

Other bug subscribers