guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 04/05: Fix bug in intmap-map


From: Andy Wingo
Subject: [Guile-commits] 04/05: Fix bug in intmap-map
Date: Sat, 26 Dec 2015 21:12:29 +0000

wingo pushed a commit to branch master
in repository guile.

commit 620b640a4eccf6fdaa9cda8dc77c415e975a1834
Author: Andy Wingo <address@hidden>
Date:   Sat Dec 26 20:16:21 2015 +0100

    Fix bug in intmap-map
    
    * module/language/cps/utils.scm (intmap-map): Use transient intmap-add!
      on an empty intmap to build the result instead of intmap-replace! on
      the argument.  Avoids spooky action-at-a-distance mutation of the
      argument if it happens to be a transient -- although the intmap-fold
      will correctly traverse a snapshot of the argument and the result will
      be correct, the argument value would be modified in place, causing
      strange results to calling code that passes in a transient.
---
 module/language/cps/utils.scm |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/module/language/cps/utils.scm b/module/language/cps/utils.scm
index 64b403d..3fce00a 100644
--- a/module/language/cps/utils.scm
+++ b/module/language/cps/utils.scm
@@ -124,9 +124,9 @@ member, or @code{#f} otherwise."
 
 (define (intmap-map proc map)
   (persistent-intmap
-   (intmap-fold (lambda (k v out) (intmap-replace! out k (proc k v)))
+   (intmap-fold (lambda (k v out) (intmap-add! out k (proc k v)))
                 map
-                map)))
+                empty-intmap)))
 
 (define (intmap-keys map)
   "Return an intset of the keys in @var{map}."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]