unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#41131: Bug in hash-table-merge! (and patch)
@ 2020-05-07 23:50 Ricardo G. Herdt
  0 siblings, 0 replies; only message in thread
From: Ricardo G. Herdt @ 2020-05-07 23:50 UTC (permalink / raw)
  To: 41131

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Hi,

I just found this bug in the hash-table-merge! function 
(modul/srfi/srfi-69.scm). Instead of merging both hash tables, it was 
ignoring one of them (other-ht). Attached is the fix, where it now folds 
over other-ht and store its data in ht.

Cheers,

Ricardo G. Herdt

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-hash-table-merge-bug.patch --]
[-- Type: text/x-diff; name=0001-Fix-hash-table-merge-bug.patch, Size: 831 bytes --]

From 180a9e14b807295aa31966a52bfd732647458ef9 Mon Sep 17 00:00:00 2001
From: "Ricardo G. Herdt" <r.herdt@posteo.de>
Date: Fri, 8 May 2020 01:37:24 +0200
Subject: [PATCH] Fix hash-table-merge! bug.

* module/srfi/srfi-69.scm : fold over second hash table.
---
 module/srfi/srfi-69.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/module/srfi/srfi-69.scm b/module/srfi/srfi-69.scm
index b9486c465..91bcc77db 100644
--- a/module/srfi/srfi-69.scm
+++ b/module/srfi/srfi-69.scm
@@ -330,7 +330,7 @@ Answer the final F result."
   "Add all key/value pairs from OTHER-HT to HT, overriding HT's
 mappings where present.  Return HT."
   (hash-table-fold
-   ht (lambda (k v ign) (hash-table-set! ht k v)) #f)
+   other-ht (lambda (k v ign) (hash-table-set! ht k v)) #f)
   ht)
 
 ;;; srfi-69.scm ends here
-- 
2.20.1


[-- Attachment #3: Changelog --]
[-- Type: text/plain, Size: 170 bytes --]

2020-05-08 Ricardo G. Herdt <r.herdt@posteo.de>

* srfi-69.scm: hash-table-merge! was ignoring the second hash table.
Fold over other-ht, and store its key-values in ht.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-07 23:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 23:50 bug#41131: Bug in hash-table-merge! (and patch) Ricardo G. Herdt

unofficial mirror of bug-guile@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-bugs/0 guile-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-bugs guile-bugs/ https://yhetil.org/guile-bugs \
		bug-guile@gnu.org
	public-inbox-index guile-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.bugs
	nntp://news.gmane.io/gmane.lisp.guile.bugs


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git