loop accumulation var does not have type declaration.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Actually, this is not a bug, just wishes.
(compile nil (lambda ()
; in: LAMBDA ()
; (COERCE CL-USER::L 'STRING)
;
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a (OR CONS NULL
; (AND (NOT (VECTOR CHARACTER)) (NOT BASE-STRING)
; VECTOR)
; SB-KERNEL:
;
; compilation unit finished
; printed 1 note
#<FUNCTION (LAMBDA ()) {5372198B}>
NIL
NIL
To muffle this note, currently, we need to wrap var (l in this case) with THE special form.
(compile nil (lambda ()
#<FUNCTION (LAMBDA ()) {5372198B}>
NIL
NIL
Ideally, user-head-var declared type automatically because
list-accumulation var is always the type of LIST.
Probably with-loop-
(sb-xc:defmacro with-loop-
((head-var tail-var &optional user-head-var) &body body)
(let ((l (and user-head-var (list (list user-head-var nil)))))
`(let* ((,head-var (list nil)) (,tail-var ,head-var) ,@l)
(declare (truly-
,@(and user-head-var `((type list ,user-head-var)))) ;;;
,@body)))
Sorry, not tested.
Changed in sbcl: | |
status: | New → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |