diff --git a/src/compiler/seqtran.lisp b/src/compiler/seqtran.lisp index 466496d..68aa5b3 100644 --- a/src/compiler/seqtran.lisp +++ b/src/compiler/seqtran.lisp @@ -1237,9 +1237,7 @@ (if from-end (setf find element position index) - (unless find - (setf find element - position index))))))))))))) + (return (values element index))))))))))))) (def %find-position-if when) (def %find-position-if-not unless)) diff --git a/tests/seq.pure.lisp b/tests/seq.pure.lisp index eb75013..1743192 100644 --- a/tests/seq.pure.lisp +++ b/tests/seq.pure.lisp @@ -222,12 +222,10 @@ (unless (eq :error got) (error "wanted an error, got ~S for~% ~S" (second got) ',lambda))))) - (test sb-kernel:bounding-indices-bad-error - (lambda () - (find :foo '(1 2 3 :foo) :start 1 :end 5))) - (test sb-kernel:bounding-indices-bad-error - (lambda () - (position :foo '(1 2 3 :foo) :start 1 :end 5))) + ;; These are OK: even though the end bounds are incorrect, the + ;; element is found before that's an issue. + (assert (eq :foo (find :foo '(1 2 3 :foo) :start 1 :end 5))) + (assert (= 3 (position :foo '(1 2 3 :foo) :start 1 :end 5))) (test sb-kernel:bounding-indices-bad-error (lambda () (find :foo '(1 2 3 :foo) :start 3 :end 0))) @@ -242,3 +240,7 @@ (lambda () (let ((list (list 1 2 3 :foo))) (position :bar (nconc list list))))))) + +(with-test (:name :bug-xxx) + ;; find-if shouldn't look through the entire list. + (assert (= 2 (find-if #'evenp '(1 2 1 1 1 1 1 1 1 1 1 1 :foo)))))