master: Don't return the data vector from (replace complex-vector list)

stassats via Sbcl-commits <[email protected]>
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  df956be42674804c273fabaa4643681282fb0273 (commit)
      from  327486b47b659a7fea388477d970d598e3b3a2f1 (commit)

- Log -----------------------------------------------------------------
commit df956be42674804c273fabaa4643681282fb0273
Author: Stas Boukarev <[email protected]>
Date:   Thu Apr 9 02:44:06 2026 +0300

    Don't return the data vector from (replace complex-vector list)
---
 src/code/seq.lisp   | 25 +++++++++++++------------
 tests/seq.pure.lisp | 10 ++++++++++
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/code/seq.lisp b/src/code/seq.lisp
index 57b3a2078..87c42c986 100644
--- a/src/code/seq.lisp
+++ b/src/code/seq.lisp
@@ -880,18 +880,19 @@
          (rplaca target-sequence-ref (aref source-sequence source-index))))))
 
 (defmacro vector-replace-from-list ()
-  `(with-array-data ((target-sequence target-sequence) (target-start target-start) (target-end target-end))
-     (cond-dispatch (simple-vector-p target-sequence)
-       (do ((target-index target-start (1+ target-index))
-            (source-index source-start (1+ source-index))
-            (source-sequence (nthcdr source-start source-sequence)
-                             (cdr source-sequence)))
-           ((or (= target-index (the fixnum target-end))
-                (= source-index (the fixnum source-end))
-                (null source-sequence))
-            target-sequence)
-         (declare (fixnum target-index source-index))
-         (setf (aref target-sequence target-index) (car source-sequence))))))
+  `(progn
+     (with-array-data ((target-sequence target-sequence) (target-start target-start) (target-end target-end))
+       (cond-dispatch (simple-vector-p target-sequence)
+         (do ((target-index target-start (1+ target-index))
+              (source-index source-start (1+ source-index))
+              (source-sequence (nthcdr source-start source-sequence)
+                               (cdr source-sequence)))
+             ((or (= target-index (the fixnum target-end))
+                  (= source-index (the fixnum source-end))
+                  (null source-sequence)))
+           (declare (fixnum target-index source-index))
+           (setf (aref target-sequence target-index) (car source-sequence)))))
+     target-sequence))
 
 (define-sequence-traverser replace
     (target-sequence1 source-sequence2 &rest args &key start1 end1 start2 end2)
diff --git a/tests/seq.pure.lisp b/tests/seq.pure.lisp
index 661b4cd67..8b11b0506 100644
--- a/tests/seq.pure.lisp
+++ b/tests/seq.pure.lisp
@@ -1127,3 +1127,13 @@
          (equalp l '(A . "FOO")))
     (('(A . "FoO")) t)
     (('(B . "FOO")) nil)))
+
+(with-test (:name :replace-vector-return)
+  (let ((v (make-array 8 :fill-pointer 5)))
+   (checked-compile-and-assert
+       ()
+       `(lambda (v s)
+          (replace v s))
+     ((v '(1 2)) v)
+     ((v #(2 3)) v)
+     ((v #9*1) v))))

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.