Skip to content

Commit 3725ef7

Browse files
committed
FIX: it was possible to modify a hidden value using extend
resolves: Oldes/Rebol-issues#2532
1 parent 514421c commit 3725ef7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/core/t-object.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ static void Extend_Obj(REBSER *obj, REBVAL *key, REBVAL *value)
8484
if (index) {
8585
if (!value) return;
8686
val = FRM_VALUE(obj, index);
87-
if (VAL_PROTECTED(val)) Trap1(RE_LOCKED_WORD, val);
87+
if (GET_FLAGS(VAL_OPTS(FRM_WORD(obj, index)), OPTS_HIDE, OPTS_LOCK)) {
88+
if (VAL_PROTECTED(val)) Trap1(RE_LOCKED_WORD, val);
89+
Trap0(RE_HIDDEN);
90+
}
8891
} else {
8992
Expand_Frame(obj, 1, 1); // copy word table also
9093
val = Append_Frame(obj, 0, VAL_WORD_SYM(key));

src/tests/units/object-test.r3

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,19 @@ Rebol [
8080
]
8181
--test-- "extend object with hidden value"
8282
;@@ https://github.com/Oldes/Rebol-issues/issues/1140
83-
obj: object [a: 1 protect/hide 'a]
83+
;@@ https://github.com/Oldes/Rebol-issues/issues/2532
84+
obj: object [a: 1 protect/hide 'a test: does [a]]
8485
--assert all [
8586
error? e: try [extend obj 'a 2]
8687
e/id = 'hidden
88+
obj/test == 1
8789
]
8890
--assert all [
8991
error? e: try [append obj [a: 2]]
9092
e/id = 'hidden
93+
obj/test == 1
9194
]
95+
9296
--test-- "append/part object!"
9397
;@@ https://github.com/Oldes/Rebol-issues/issues/1754
9498
--assert [] == body-of append/part make object! [] [a 1 b 2 c 3] 1

0 commit comments

Comments
 (0)