Skip to content

Commit

Permalink
FIX: Make UNSET of unbound words cause error vs. fail silently
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jul 5, 2020
1 parent c4162f9 commit 7525f82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/n-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,11 @@ static int Check_Char_Range(REBVAL *val, REBINT limit)
Protected(word);
value = Get_Var(word);
SET_UNSET(value);
}
} else Trap1(RE_NOT_DEFINED, word);
} else {
for (word = VAL_BLK_DATA(word); NOT_END(word); word++) {
if (IS_WORD(word) && VAL_WORD_FRAME(word)) {
if (IS_WORD(word)) {
if (!VAL_WORD_FRAME(word)) Trap1(RE_NOT_DEFINED, word);
Protected(word);
value = Get_Var(word);
SET_UNSET(value);
Expand Down
4 changes: 4 additions & 0 deletions src/tests/units/evaluation-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ Rebol [
;@@ https://github.com/Oldes/Rebol-issues/issues/2003
--assert none? to-value #[unset!]
--assert integer? to-value 1

--test-- "unset unbind 'x"
;@@ https://github.com/Oldes/Rebol-issues/issues/2219
--assert error? try [unset unbind 'x]

===end-group===

Expand Down

0 comments on commit 7525f82

Please sign in to comment.