bug-guile
[Top][All Lists]
Advanced

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

bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored


From: Taylan Ulrich Bayırlı/Kammer
Subject: bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored
Date: Sun, 24 Jan 2016 12:44:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

I forgot to change the test suite accordingly.  Here's an updated patch.

>From 7483d98cf1e5439ac62ee8da3e216a413853b40c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <address@hidden>
Date: Sat, 23 Jan 2016 22:35:24 +0100
Subject: [PATCH 1/2] Hashtable-set! errors on immutable hashtable.

* module/rnrs/hashtables.scm (hashtable-set!): Raise an assertion
  violation error when the hashtable is immutable.
---
 module/rnrs/hashtables.scm            | 5 +++--
 test-suite/tests/r6rs-hashtables.test | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/module/rnrs/hashtables.scm b/module/rnrs/hashtables.scm
index 98d2d76..5773eb1 100644
--- a/module/rnrs/hashtables.scm
+++ b/module/rnrs/hashtables.scm
@@ -122,8 +122,9 @@
 
   (define (hashtable-set! hashtable key obj)
     (if (r6rs:hashtable-mutable? hashtable)
-       (hash-table-set! (r6rs:hashtable-wrapped-table hashtable) key obj))
-    *unspecified*)
+        (hash-table-set! (r6rs:hashtable-wrapped-table hashtable) key obj)
+        (assertion-violation
+         'hashtable-set! "Hashtable is immutable." hashtable)))
 
   (define (hashtable-delete! hashtable key)
     (if (r6rs:hashtable-mutable? hashtable)
diff --git a/test-suite/tests/r6rs-hashtables.test 
b/test-suite/tests/r6rs-hashtables.test
index c7812c5..dbf6859 100644
--- a/test-suite/tests/r6rs-hashtables.test
+++ b/test-suite/tests/r6rs-hashtables.test
@@ -20,6 +20,7 @@
 (define-module (test-suite test-rnrs-hashtable)
   :use-module (ice-9 receive)
   :use-module ((rnrs hashtables) :version (6))
+  :use-module ((rnrs exceptions) :version (6))
   :use-module (srfi srfi-1)
   :use-module (test-suite lib))
 
@@ -130,8 +131,9 @@
 
   (pass-if "hashtable-copy with mutability #f produces immutable copy"
     (let ((copied-table (hashtable-copy (make-eq-hashtable) #f)))
-      (hashtable-set! copied-table 'foo 1)
-      (not (hashtable-ref copied-table 'foo #f)))))      
+      (guard (exc (else #t))
+        (hashtable-set! copied-table 'foo 1)
+        #f))))
 
 (with-test-prefix "hashtable-clear!"
   (pass-if "hashtable-clear! removes all values from hashtable"
-- 
2.6.3


reply via email to

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