Skip to content

Commit

Permalink
CHANGE: made foreach consistent with keys-of in the map! context
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Sep 6, 2024
1 parent f5b43c5 commit 5fc91ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/n-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ enum loop_each_mode {
if (!VAL_GET_OPT(BLK_SKIP(series, index), OPTS_HIDE)) {
if (j == 0) {
*vars = *BLK_SKIP(series, index & ~1);
#ifndef DO_NOT_NORMALIZE_MAP_KEYS
if (IS_SET_WORD(vars)) SET_TYPE(vars, REB_WORD);
#endif
if (IS_END(vars+1)) index++; // only words
}
else if (j == 1)
Expand Down
9 changes: 9 additions & 0 deletions src/tests/units/map-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ Rebol [
m: make map! [1-1-2000 1 10:00 2 1.1.1 3 ]
--assert [1-Jan-2000 10:00 1.1.1] = keys-of m

--test-- "foreach consistent with keys-of"
;@@ https://github.com/red/red/issues/5533
m: make map! []
m/a: 1
--assert [a] == keys-of m
b: copy []
foreach [k v] m [append b k]
--assert [a] == b

===end-group===

===start-group=== "MAP with NONE"
Expand Down

0 comments on commit 5fc91ac

Please sign in to comment.