Skip to content

Commit

Permalink
FIX: foreach not seeing none values in map!
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jan 20, 2021
1 parent 01d5c25 commit b7118b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/n-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@
}

else if (IS_MAP(value)) {
REBVAL *val = BLK_SKIP(series, index | 1);
if (!IS_NONE(val)) {
if (!VAL_GET_OPT(BLK_SKIP(series, index), OPTS_HIDE)) {
if (j == 0) {
*vars = *BLK_SKIP(series, index & ~1);
if (IS_END(vars+1)) index++; // only words
Expand Down
6 changes: 6 additions & 0 deletions src/tests/units/map-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,19 @@ Rebol [
===end-group===

===start-group=== "MAP with NONE"
;@@ https://github.com/Oldes/Rebol-wishes/issues/21
--test-- "map with none"
m: #(a: #[none] b: 1)
m/b: none
--assert [a b] = keys-of m
--assert [#[none] #[none]] = values-of m
--test-- "foreach on map with none"
o: copy ""
foreach [k v] m [append o k]
--assert o = "ab"

--test-- "remove from map"
;@@ https://github.com/Oldes/Rebol-wishes/issues/20
m: #("ab" 1 "AB" 2)
--assert ["ab" 1 "AB" 2] = to block! remove/key m "aB"
--assert 2 = length? m
Expand Down

0 comments on commit b7118b7

Please sign in to comment.