Subject: bug#13838: closed (Re: bug#13838: [PATCH] Fix duplicate removal of with-fluids)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 28 Feb 2013 11:34:01 +0000

Your bug report

#13838: [PATCH] Fix duplicate removal of with-fluids

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
13838: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13838
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#13838: [PATCH] Fix duplicate removal of with-fluids
From: Mark H Weaver <[email-masked]>
To: David Kastrup <[email-masked]>
Cc: [email-masked]
Date: Thu, 28 Feb 2013 06:31:49 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Applied, thanks.

     Mark

Subject: [PATCH] Fix duplicate removal of with-fluids
From: David Kastrup <[email-masked]>
To: [email-masked]
Cc: David Kastrup <[email-masked]>
Date: Thu, 28 Feb 2013 10:40:16 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

The following code displayed #f:

(define a (make-fluid))
(define b (make-fluid))
(with-fluids ((a 3) (a 1) (b 2))
	     (display (fluid-ref b)))

In general, removing any duplicate that is not right at the end of the
(remaining) list will exhibit this problem.  The fluids and vals
arguments are modified in situ; the previous code only modified vals.
---
 libguile/fluids.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/libguile/fluids.c b/libguile/fluids.c
index f1c09cb..bd59e26 100644
--- a/libguile/fluids.c
+++ b/libguile/fluids.c
@@ -326,6 +326,8 @@ scm_i_make_with_fluids (size_t n, SCM *fluids, SCM *vals)
           {
             vals[i] = vals[j]; /* later bindings win */
             n--;
+            fluids[j] = fluids[n];
+            vals[j] = vals[n];
             break;
           }
   }
-- 
1.7.10.4