unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored
@ 2016-01-23 21:19 "Taylan Ulrich Bayırlı/Kammer"
  2016-01-23 23:19 ` Taylan Ulrich Bayırlı/Kammer
  0 siblings, 1 reply; 5+ messages in thread
From: "Taylan Ulrich Bayırlı/Kammer" @ 2016-01-23 21:19 UTC (permalink / raw)
  To: 22447

I couldn't find explicit wording in R6RS on what should happen, but I
would generally expect an attempt to mutate an immutable object to
raise an error.  In Guile,

    (hashtable-set! (hashtable-copy (make-eq-hashtable)) 'foo 'bar)

is silently ignored.

Taylan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored
  2016-01-23 21:19 bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored "Taylan Ulrich Bayırlı/Kammer"
@ 2016-01-23 23:19 ` Taylan Ulrich Bayırlı/Kammer
  2016-01-24 11:44   ` Taylan Ulrich Bayırlı/Kammer
  0 siblings, 1 reply; 5+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2016-01-23 23:19 UTC (permalink / raw)
  To: 22447

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

Sorry about the duplicate bug report; I merged it into this one.

Here's the patch again.  (Merged report seemed invisible in the web
interface.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Hashtable-set-errors-on-immutable-hashtable.patch --]
[-- Type: text/x-diff, Size: 1112 bytes --]

From dd6c4bbbe85a57fcbb08bdc7847075bddc1f0d87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Sat, 23 Jan 2016 22:35:24 +0100
Subject: [PATCH] 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 +++--
 1 file changed, 3 insertions(+), 2 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)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored
  2016-01-23 23:19 ` Taylan Ulrich Bayırlı/Kammer
@ 2016-01-24 11:44   ` Taylan Ulrich Bayırlı/Kammer
  2016-06-20 22:33     ` Taylan Ulrich Bayırlı/Kammer
  0 siblings, 1 reply; 5+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2016-01-24 11:44 UTC (permalink / raw)
  To: 22447

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

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Hashtable-set-errors-on-immutable-hashtable.patch --]
[-- Type: text/x-diff, Size: 2106 bytes --]

From 7483d98cf1e5439ac62ee8da3e216a413853b40c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored
  2016-01-24 11:44   ` Taylan Ulrich Bayırlı/Kammer
@ 2016-06-20 22:33     ` Taylan Ulrich Bayırlı/Kammer
  2016-06-21  7:47       ` Andy Wingo
  0 siblings, 1 reply; 5+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2016-06-20 22:33 UTC (permalink / raw)
  To: 22447

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

Pinging this thread with a (very slightly) updated patch. :-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Hashtable-set-errors-on-immutable-hashtable.patch --]
[-- Type: text/x-diff, Size: 2160 bytes --]

From 7f35d515d711e255bba5a89a013d9d92034edf41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Tue, 21 Jun 2016 00:25:19 +0200
Subject: [PATCH] Hashtable-set! errors on immutable hashtable.

* module/rnrs/hashtables.scm (hashtable-set!): Raise an assertion
  violation error when the hashtable is immutable.
* test-suite/tests/r6rs-hashtables.test: Fix accordingly.
---
 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 08f37e2..22bae7f 100644
--- a/module/rnrs/hashtables.scm
+++ b/module/rnrs/hashtables.scm
@@ -127,8 +127,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 fbc50c9..e2cbc2a 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.8.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored
  2016-06-20 22:33     ` Taylan Ulrich Bayırlı/Kammer
@ 2016-06-21  7:47       ` Andy Wingo
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Wingo @ 2016-06-21  7:47 UTC (permalink / raw)
  To: Taylan Ulrich "Bayırlı/Kammer"; +Cc: 22447-done

Applied to master, thanks :)

Andy

On Tue 21 Jun 2016 00:33, taylanbayirli@gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:

> Pinging this thread with a (very slightly) updated patch. :-)
>
>
> From 7f35d515d711e255bba5a89a013d9d92034edf41 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
>  <taylanbayirli@gmail.com>
> Date: Tue, 21 Jun 2016 00:25:19 +0200
> Subject: [PATCH] Hashtable-set! errors on immutable hashtable.
>
> * module/rnrs/hashtables.scm (hashtable-set!): Raise an assertion
>   violation error when the hashtable is immutable.
> * test-suite/tests/r6rs-hashtables.test: Fix accordingly.
> ---
>  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 08f37e2..22bae7f 100644
> --- a/module/rnrs/hashtables.scm
> +++ b/module/rnrs/hashtables.scm
> @@ -127,8 +127,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 fbc50c9..e2cbc2a 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"





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-21  7:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23 21:19 bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored "Taylan Ulrich Bayırlı/Kammer"
2016-01-23 23:19 ` Taylan Ulrich Bayırlı/Kammer
2016-01-24 11:44   ` Taylan Ulrich Bayırlı/Kammer
2016-06-20 22:33     ` Taylan Ulrich Bayırlı/Kammer
2016-06-21  7:47       ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).