Skip to content

Commit 0605fd5

Browse files
committed
FIX: equality of objects with hidden values
resolves: Oldes/Rebol-issues#1778
1 parent b917152 commit 0605fd5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/core/t-object.c

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ static REBOOL Equal_Object(REBVAL *val, REBVAL *arg)
6262

6363
// Compare each entry:
6464
for (n = 1; n < (REBINT)(f1->tail); n++) {
65+
if (VAL_HIDDEN(BLK_SKIP(w1, n))) return VAL_HIDDEN(BLK_SKIP(w2, n));
66+
if (VAL_HIDDEN(BLK_SKIP(w2, n))) return VAL_HIDDEN(BLK_SKIP(w1, n));
6567
if (Cmp_Value(BLK_SKIP(w1, n), BLK_SKIP(w2, n), FALSE)) return FALSE;
6668
// Use Compare_Values();
6769
if (Cmp_Value(BLK_SKIP(f1, n), BLK_SKIP(f2, n), FALSE)) return FALSE;

src/tests/units/protect-test.r3

+8
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ Rebol [
166166
a: "123"
167167
--assert all [error? e: try [protect/hide :a] e/id = 'bad-refines]
168168

169+
--test-- "compare objects with hidden values"
170+
;@@ https://github.com/Oldes/Rebol-issues/issues/1778
171+
--assert equal? context [a: 1 protect/hide 'a] context [a: 2 protect/hide 'a]
172+
--assert equal? context [a: 1 protect/hide 'a] context [a: 1 protect/hide 'a]
173+
--assert equal? context [a: 1 protect/hide 'a] context [b: 1 protect/hide 'b]
174+
--assert not equal? context [a: 1 protect/hide 'a] context [a: 1]
175+
--assert not equal? context [a: 1] context [a: 1 protect/hide 'a]
176+
--assert not equal? context [a: 1 protect/hide 'a] context []
169177

170178
===end-group===
171179

0 commit comments

Comments
 (0)