Skip to content

Commit c1594e2

Browse files
committed
FIX: UNIQUE/DIFFERENCE/INTERSECT/UNION/EXCLUDE do not accept some data types
fixes: Oldes/Rebol-issues#1765
1 parent 1d9790d commit c1594e2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/core/t-map.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@
128128
// Compute hash for value:
129129
len = hser->tail;
130130
hash = Hash_Value(key, len);
131-
if (!hash) Trap_Type(key);
131+
//o: use fallback hash value, if key is not a hashable type, instead of an error
132+
//o: https://github.com/Oldes/Rebol-issues/issues/1765
133+
if (!hash) hash = 3 * (len/5); //Trap_Type(key);
132134

133135
// Determine skip and first index:
134136
skip = (len == 0) ? 0 : (hash & 0x0000FFFF) % len;

src/tests/units/series-test.r3

+14
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,20 @@ Rebol [
13451345

13461346
===end-group===
13471347

1348+
===start-group=== "More set operations"
1349+
--test-- "unhashable types"
1350+
;@@ https://github.com/Oldes/Rebol-issues/issues/1765
1351+
blk1: reduce ["a" [1 2 3] 'path/path func [][] charset ["a"]]
1352+
blk2: append copy blk1 blk1
1353+
--assert blk1 = unique blk2
1354+
--assert blk1 = union blk1 blk2
1355+
append blk2 blk3: ["b" [3 4]]
1356+
--assert blk1 = intersect blk2 blk1
1357+
--assert blk3 = difference blk1 blk2
1358+
--assert blk3 = exclude blk2 blk1
1359+
--assert empty? exclude blk1 blk2
1360+
===end-group===
1361+
13481362
===start-group=== "TO-*"
13491363

13501364
--test-- "to-path"

0 commit comments

Comments
 (0)