Skip to content

Commit

Permalink
FIX: it was possible to modify a hidden value using extend
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jan 30, 2023
1 parent 514421c commit 3725ef7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/t-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ static void Extend_Obj(REBSER *obj, REBVAL *key, REBVAL *value)
if (index) {
if (!value) return;
val = FRM_VALUE(obj, index);
if (VAL_PROTECTED(val)) Trap1(RE_LOCKED_WORD, val);
if (GET_FLAGS(VAL_OPTS(FRM_WORD(obj, index)), OPTS_HIDE, OPTS_LOCK)) {
if (VAL_PROTECTED(val)) Trap1(RE_LOCKED_WORD, val);
Trap0(RE_HIDDEN);
}
} else {
Expand_Frame(obj, 1, 1); // copy word table also
val = Append_Frame(obj, 0, VAL_WORD_SYM(key));
Expand Down
6 changes: 5 additions & 1 deletion src/tests/units/object-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,19 @@ Rebol [
]
--test-- "extend object with hidden value"
;@@ https://github.com/Oldes/Rebol-issues/issues/1140
obj: object [a: 1 protect/hide 'a]
;@@ https://github.com/Oldes/Rebol-issues/issues/2532
obj: object [a: 1 protect/hide 'a test: does [a]]
--assert all [
error? e: try [extend obj 'a 2]
e/id = 'hidden
obj/test == 1
]
--assert all [
error? e: try [append obj [a: 2]]
e/id = 'hidden
obj/test == 1
]

--test-- "append/part object!"
;@@ https://github.com/Oldes/Rebol-issues/issues/1754
--assert [] == body-of append/part make object! [] [a 1 b 2 c 3] 1
Expand Down

0 comments on commit 3725ef7

Please sign in to comment.