From b7118b71860c0ede346abe116bfad6707071f936 Mon Sep 17 00:00:00 2001 From: Oldes Date: Wed, 20 Jan 2021 19:06:48 +0100 Subject: [PATCH] FIX: `foreach` not seeing `none` values in `map!` resolves: https://github.com/Oldes/Rebol-wishes/issues/21 --- src/core/n-loop.c | 3 +-- src/tests/units/map-test.r3 | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/n-loop.c b/src/core/n-loop.c index bdbc252617..b30d7c19e9 100644 --- a/src/core/n-loop.c +++ b/src/core/n-loop.c @@ -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 diff --git a/src/tests/units/map-test.r3 b/src/tests/units/map-test.r3 index fbe028c4c2..5415d4aa61 100644 --- a/src/tests/units/map-test.r3 +++ b/src/tests/units/map-test.r3 @@ -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