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


View this message in rfc822 format

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: bug#39634: All keyowrds hash to the same value
Date: Fri, 06 Mar 2020 15:42:20 +0100
[Message part 1 (text/plain, inline)]
Andy Wingo <wingo <at> igalia.com> skribis:

>>   variable,
>>   hashtable,
>>   fluid,
>>   dynamic_state,
>>   frame,
>>   atomic_box,
>>   program,
>>   vm_cont,
>>   weak_set,
>>   weak_table,
>>   port
>
> No equal? implementation, so should hashq() instead.

Here’s a patch for these, let me know what you think!

(Of course longer term it’d be nice to have a centralized way to declare
each tc7 with its equal and hash methods.)

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/libguile/hash.c b/libguile/hash.c
index c51a794c9..9cb8fcedd 100644
--- a/libguile/hash.c
+++ b/libguile/hash.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-1997,2000-2001,2003-2004,2006,2008-2015,2017-2018
+/* Copyright 1995-1997,2000-2001,2003-2004,2006,2008-2015,2017-2018,2020
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -331,6 +331,22 @@ scm_raw_ihash (SCM obj, size_t depth)
         h ^= scm_raw_ihash (scm_syntax_module (obj), depth);
         return h;
       }
+
+      /* The following tc7s have no 'equal?' implementation.  Thus, just
+         fall back to 'hashq'.  */
+    case scm_tc7_variable:
+    case scm_tc7_hashtable:
+    case scm_tc7_fluid:
+    case scm_tc7_dynamic_state:
+    case scm_tc7_frame:
+    case scm_tc7_atomic_box:
+    case scm_tc7_program:
+    case scm_tc7_vm_cont:
+    case scm_tc7_weak_set:
+    case scm_tc7_weak_table:
+    case scm_tc7_port:
+      return scm_raw_ihashq (SCM_UNPACK (obj));
+
     case scm_tcs_cons_imcar: 
     case scm_tcs_cons_nimcar:
       if (depth)

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.