1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 15:00:21 +02:00

Fix a bug in `vhash-delete'.

* module/ice-9/vlist.scm (vhash-delete): Honor HASH.
* test-suite/tests/vlist.test ("vhash")["vhash-delete honors HASH"]: New test.
This commit is contained in:
Ludovic Courtès 2011-02-22 00:32:00 +01:00
parent 1e1808c920
commit da0c22b5d3
2 changed files with 14 additions and 2 deletions

View file

@ -536,7 +536,7 @@ with @var{equal?}."
(v (cdr k+v))) (v (cdr k+v)))
(if (equal? k key) (if (equal? k key)
result result
(vhash-cons k v result)))) (vhash-cons k v result hash))))
vlist-null vlist-null
vhash) vhash)
vhash)) vhash))

View file

@ -2,7 +2,7 @@
;;;; ;;;;
;;;; Ludovic Courtès <ludo@gnu.org> ;;;; Ludovic Courtès <ludo@gnu.org>
;;;; ;;;;
;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. ;;;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -282,6 +282,18 @@
#t #t
keys))))) keys)))))
(pass-if "vhash-delete honors HASH"
;; In 2.0.0, `vhash-delete' would construct a new vhash without
;; using the supplied hash procedure, which could lead to
;; inconsistencies.
(let* ((s "hello")
(vh (fold vhash-consq
(vhash-consq s "world" vlist-null)
(iota 300)
(iota 300))))
(and (vhash-assq s vh)
(pair? (vhash-assq s (vhash-delete 123 vh eq? hashq))))))
(pass-if "vhash-fold" (pass-if "vhash-fold"
(let* ((keys '(a b c d e f g d h i)) (let* ((keys '(a b c d e f g d h i))
(values '(1 2 3 4 5 6 7 0 8 9)) (values '(1 2 3 4 5 6 7 0 8 9))