summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Boukarev <stassats@gmail.com>2024-09-20 01:44:41 +0300
committerStas Boukarev <stassats@gmail.com>2024-09-20 01:52:19 +0300
commit6814afda28dbf45d981e643822f2edf27380767d (patch)
treee520d29c7b22664ae4f1d457bd471cada4ab908a
parent5dad9a4902bef2f9bc10bcd21a9751295bdb86c2 (diff)
Check for :start in find/position on lists.
Not just :end.
-rw-r--r--src/compiler/seqtran.lisp6
-rw-r--r--tests/seq.pure.lisp4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/seqtran.lisp b/src/compiler/seqtran.lisp
index b99ddfed9..0eff1dec6 100644
--- a/src/compiler/seqtran.lisp
+++ b/src/compiler/seqtran.lisp
@@ -2601,10 +2601,12 @@
(bounds-error)
(do ((slow sequence (cdr slow))
,@(when safe '((fast (cdr sequence) (cddr fast))))
- ,@(when indexed '((index 0 (+ index 1)))))
+ ,@(when indexed '((index 0 (truly-the index (+ index 1))))))
((cond ((null slow)
(,@(if indexed
- '(if (and end (> end index)) (bounds-error))
+ '(if (or (> start index)
+ (and end (> end index)))
+ (bounds-error))
'(progn))
(return (values find position))))
,@(when indexed
diff --git a/tests/seq.pure.lisp b/tests/seq.pure.lisp
index db7b8523d..6b9769dca 100644
--- a/tests/seq.pure.lisp
+++ b/tests/seq.pure.lisp
@@ -256,6 +256,10 @@
'(find :foo '(1 2 3 :foo) :start 3 :end 0 :from-end t))
(test 'sb-kernel:bounding-indices-bad-error
'(position :foo '(1 2 3 :foo) :start 3 :end 0 :from-end t))
+ (test 'sb-kernel:bounding-indices-bad-error
+ '(find :foo '(1 2 3) :start 5))
+ (test 'sb-kernel:bounding-indices-bad-error
+ '(position :foo '(1 2 3) :start 5 :from-end t))
(test 'type-error
'(let ((list (list 1 2 3 :foo)))
(find :bar (nconc list list)))