GNU bug report logs - #39634
All keyowrds hash to the same value

Previous Next

Package: guile;

Reported by: Rob Browning <rlb <at> defaultvalue.org>

Date: Sun, 16 Feb 2020 18:22:02 UTC

Severity: important

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #19 received at 39634 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andy Wingo <wingo <at> igalia.com>
Cc: 39634 <at> debbugs.gnu.org, Rob Browning <rlb <at> defaultvalue.org>
Subject: Re: bug#39634: All keyowrds hash to the same value
Date: Wed, 26 Feb 2020 22:02:29 +0100
Hi Andy!

Andy Wingo <wingo <at> igalia.com> skribis:

> On Thu 20 Feb 2020 17:19, Ludovic Courtès <ludo <at> gnu.org> writes:
>
>> Of all the scm_tc7_ values listed in ‘scm.h’, the following are not
>> explicitly listed (so they go to the default case that hashes the first
>> word):
>
> Reformatting your list so I can check one by one :)
>
>>   variable,
>>   hashtable,
>>   fluid,
>>   dynamic_state,
>>   frame,
>>   atomic_box,
>>   program,
>>   vm_cont,
>>   weak_set,
>>   weak_table,
>>   port
>
> No equal? implementation, so should hashq() instead.
>
>>   bytevector,
>>   array,
>>   bitvector,
>
> These have equal? implementations, and what's more, a bitvector can
> equal? an array... I think we have another bug!
>
>   ;; Project 2d array as 1d array (scm_tc7_array)
>   (define x
>     (make-shared-array #2b((#t #t #t)) (lambda (i) (list 0 i)) '(0 2)))
>   ;; scm_tc7_bitvector
>   (define y #*111)
>
>   (equal? x y) ;; => #t
>   (equal? (hash x #xffffffff) (hash y #xffffffff)) ;; => #f
>             
> Similarly for 1-d scm_tc7_array versus regular vectors, bytevectors,
> etc.

Oops.

> Fixing this will not be straightforward...  I think basically 1d arrays
> need some special hashing logic so that e.g. vectors and 1d arrays hash
> to the same thing.

OK.

>>   stringbuf,
>>   values,
>
> These are never exposed to Scheme, and never compared using equal?
> AFAIU.  No need for special cases.

Agreed.

> Basically I think the tc7 case should default to hashq, and include
> special cases for the ones that have equal? implementations or which
> have read syntax.
>
> Sound right to you?

It does, yes.

Thanks for looking into it,
Ludo’.




This bug report was last modified 5 years and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.