Error in implementation of hashing for make-wrapper-comparator Peter McGoron 16 Jul 2025 15:17 UTC

The implementation of make-wrapper-comparator does not unwrap the value
prior to hashing it, causing a type error in most uses of it.

The following patch fixes that, and adds a test case for hashing.

---
  srfi-228-test.scm | 5 +++++
  srfi/srfi-228.scm | 3 ++-
  2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/srfi-228-test.scm b/srfi-228-test.scm
index f6a984d..fa15104 100644
--- a/srfi-228-test.scm
+++ b/srfi-228-test.scm
@@ -30,6 +30,11 @@
          (make-person "Tom" "Smith")
          (make-person "John" "Smith"))))

+(test-group "hashing"
+  (test-assert
+   (= (comparator-hash person-name-comparator (make-person "Tom" "Smith"))
+      (comparator-hash person-name-comparator (make-person "Tom"
"smith")))))
+
  (define-record-type Book
      (make-book author title)
      book?
diff --git a/srfi/srfi-228.scm b/srfi/srfi-228.scm
index 139093f..3d9b22f 100644
--- a/srfi/srfi-228.scm
+++ b/srfi/srfi-228.scm
@@ -13,7 +13,8 @@
         #f)
    (if (comparator-hash-function contents-comparator)
        (lambda (x)
-        ((comparator-hash-function contents-comparator) x))
+        ((comparator-hash-function contents-comparator)
+         (unwrap x)))
        #f)))

  (define (make-product-comparator . comparators)
--
2.45.3