Sequence function compilation fails with weird cons types

Bug #1980292 reported by James Kalenius
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

(defun s (x) (declare (type (cons (eql 5)) x)) (car (sort x #'<)))

(s (list 5 4)) => 5. correct answer is 4.

I believe this is because the derive-type for SORT just returns the type of the sequence,
which in this case is too specific. SBCL then constant folds the whole function to 5 (and
warns that it is discarding the result of SORT).
You can see similar problems with FILL and other functions with similar derive-type methods.

This is on SBCL 2.2.5.

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.