Re: Fwd: Error in implementation of hashing for make-wrapper-comparator
Peter McGoron 11 Oct 2025 17:51 UTC
Is there any update on this?
-- Peter McGoron
On 7/24/25 00:39, Arthur A. Gleckler wrote:
> Hi, Daphne. Would you please take a look at Peter's fix?
>
> Thanks.
>
> ---------- Forwarded message ---------
> From: *Peter McGoron* <xxxxxx@mcgoron.com <mailto:xxxxxx@mcgoron.com>>
> Date: Wed, Jul 16, 2025 at 8:23 AM
> Subject: Error in implementation of hashing for make-wrapper-comparator
> To: <xxxxxx@srfi.schemers.org <mailto:xxxxxx@srfi.schemers.org>>
>
>
> 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
>
>