Skip to content

Commit 09e8c42

Browse files
committed
FEAT: allow SIGNED word as a key word in vector construction dialect as a oposite to already supported UNSIGNED
Implements: metaeducation/rebol-issues#2395
1 parent 5ff05b1 commit 09e8c42

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/core/t-vector.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,12 @@ void Set_Vector_Row(REBSER *ser, REBVAL *blk)
484484
REBSER *vect;
485485
REBVAL *iblk = 0;
486486

487-
// UNSIGNED
488-
if (IS_WORD(bp) && VAL_WORD_CANON(bp) == SYM_UNSIGNED) {
489-
sign = 1;
490-
bp++;
487+
// SIGNED / UNSIGNED
488+
if (IS_WORD(bp)) {
489+
switch (VAL_WORD_CANON(bp)) {
490+
case SYM_UNSIGNED: sign = 1; bp++; break;
491+
case SYM_SIGNED: sign = 0; bp++; break;
492+
}
491493
}
492494

493495
// INTEGER! or DECIMAL!

src/tests/units/vector-test.r3

+5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ Rebol [
9292
--assert 2 = index? v: make vector! [integer! 16 [1 2] 2]
9393
--assert 2 = index? v: make vector! [integer! 16 #{01000200} 2]
9494

95+
--test-- "issue/2395"
96+
;@@ https://github.com/rebol/rebol-issues/issues/2395
97+
--assert "make vector! [integer! 32 2 [0 0]]" = mold make vector! [signed integer! 32 2]
98+
--assert "make vector! [unsigned integer! 32 2 [0 0]]" = mold make vector! [unsigned integer! 32 2]
99+
95100
--test-- "MOLD/flat on vector"
96101
;@@ https://github.com/rebol/rebol-issues/issues/2349
97102
--assert (mold/flat make vector! [integer! 8 12]) = {make vector! [integer! 8 12 [0 0 0 0 0 0 0 0 0 0 0 0]]}

0 commit comments

Comments
 (0)