Skip to content

Commit

Permalink
FIX: equality of objects with hidden values
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jun 20, 2023
1 parent b917152 commit 0605fd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/t-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static REBOOL Equal_Object(REBVAL *val, REBVAL *arg)

// Compare each entry:
for (n = 1; n < (REBINT)(f1->tail); n++) {
if (VAL_HIDDEN(BLK_SKIP(w1, n))) return VAL_HIDDEN(BLK_SKIP(w2, n));
if (VAL_HIDDEN(BLK_SKIP(w2, n))) return VAL_HIDDEN(BLK_SKIP(w1, n));
if (Cmp_Value(BLK_SKIP(w1, n), BLK_SKIP(w2, n), FALSE)) return FALSE;
// Use Compare_Values();
if (Cmp_Value(BLK_SKIP(f1, n), BLK_SKIP(f2, n), FALSE)) return FALSE;
Expand Down
8 changes: 8 additions & 0 deletions src/tests/units/protect-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ Rebol [
a: "123"
--assert all [error? e: try [protect/hide :a] e/id = 'bad-refines]

--test-- "compare objects with hidden values"
;@@ https://github.com/Oldes/Rebol-issues/issues/1778
--assert equal? context [a: 1 protect/hide 'a] context [a: 2 protect/hide 'a]
--assert equal? context [a: 1 protect/hide 'a] context [a: 1 protect/hide 'a]
--assert equal? context [a: 1 protect/hide 'a] context [b: 1 protect/hide 'b]
--assert not equal? context [a: 1 protect/hide 'a] context [a: 1]
--assert not equal? context [a: 1] context [a: 1 protect/hide 'a]
--assert not equal? context [a: 1 protect/hide 'a] context []

===end-group===

Expand Down

0 comments on commit 0605fd5

Please sign in to comment.