Skip to content

Commit 35815ce

Browse files
committed
FIX: COPY/part on VECTOR is silently ignored
fixes: metaeducation/rebol-issues#2399
1 parent 1162e7d commit 35815ce

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/core/t-vector.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ void Set_Vector_Row(REBSER *ser, REBVAL *blk)
683683
REBSER *ser;
684684
REBSER *blk;
685685
REBVAL *val;
686+
REBINT len;
686687

687688
type = Do_Series_Action(action, value, arg);
688689
if (type >= 0) return type;
@@ -742,7 +743,8 @@ void Set_Vector_Row(REBSER *ser, REBVAL *blk)
742743
return R_RET;
743744

744745
case A_COPY:
745-
ser = Copy_Series(vect);
746+
len = Partial(value, 0, D_ARG(3), 0); // Can modify value index.
747+
ser = Copy_Series_Part(vect, VAL_INDEX(value), len);
746748
ser->size = vect->size; // attributes
747749
SET_VECTOR(value, ser);
748750
break;

src/tests/units/vector-test.r3

+11
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,15 @@ Rebol [
357357

358358
===end-group===
359359

360+
===start-group=== "VECTOR copy"
361+
362+
--test-- "COPY/PART"
363+
;@@ https://github.com/rebol/rebol-issues/issues/2399
364+
v: #[ui16! [1 2 3 4]]
365+
--assert 2 = length? copy/part v 2
366+
--assert #{01000200} = to-binary copy/part v 2
367+
--assert #{03000400} = to-binary copy/part skip v 2 2
368+
369+
===end-group===
370+
360371
~~~end-file~~~

0 commit comments

Comments
 (0)