Skip to content

Commit

Permalink
CHANGE: allow unset none to be a no-op instead of throwing an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Dec 17, 2020
1 parent 97cae72 commit b71d816
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/boot/natives.reb
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ type?: native [

unset: native [
{Unsets the value of a word (in its current context.)}
word [word! block!] {Word or block of words}
word [word! block! none!] {Word or block of words}
]

utf?: native [
Expand Down
3 changes: 3 additions & 0 deletions src/core/n-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ static int Check_Char_Range(REBVAL *val, REBINT limit)
value = Get_Var(word);
SET_UNSET(value);
} else Trap1(RE_NOT_DEFINED, word);
} else if (IS_NONE(word)) {
// https://github.com/Oldes/Rebol-wishes/issues/28
return R_NONE;
} else {
for (word = VAL_BLK_DATA(word); NOT_END(word); word++) {
if (IS_WORD(word)) {
Expand Down
18 changes: 18 additions & 0 deletions src/tests/units/object-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Rebol [
--assert not same? a b
===end-group===


===start-group=== "Object actions"
--test-- "empty?"
;@@ https://github.com/Oldes/Rebol-issues/issues/1669
Expand All @@ -215,6 +216,23 @@ Rebol [
===end-group===


===start-group=== "UNSET in object"
--test-- "unset ctx"
ctx: context [a: 1 b: 2 c: 3]
--assert unset? unset in ctx 'a
--assert unset? unset bind [b c] ctx
--assert all [
unset? :ctx/a
unset? :ctx/b
unset? :ctx/c
]
;@@ https://github.com/Oldes/Rebol-wishes/issues/28
--assert none? unset in ctx 'd


===end-group===


===start-group=== "APPEND on OBJECT"
;@@ https://github.com/Oldes/Rebol-issues/issues/708
--test-- "issue-708"
Expand Down

0 comments on commit b71d816

Please sign in to comment.