From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?UTF-8?Q?Bay=C4=B1rl=C4=B1/Kammer?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#22447: (rnrs hashtables): Mutation of immutable hashtable ignored Date: Tue, 21 Jun 2016 00:33:50 +0200 Message-ID: <8760t3qylt.fsf@T420.taylan> References: <87lh7fkhoq.fsf@T420.taylan> <87h9i3jj5y.fsf@T420.taylan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1466462180 8408 80.91.229.3 (20 Jun 2016 22:36:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 22:36:20 +0000 (UTC) To: 22447@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Jun 21 00:36:13 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bF7nh-00006O-01 for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 00:36:13 +0200 Original-Received: from localhost ([::1]:46902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF7nb-0007uL-Cv for guile-bugs@m.gmane.org; Mon, 20 Jun 2016 18:36:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF7le-0006AJ-7K for bug-guile@gnu.org; Mon, 20 Jun 2016 18:34:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF7la-0005tt-6I for bug-guile@gnu.org; Mon, 20 Jun 2016 18:34:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF7la-0005tp-1t for bug-guile@gnu.org; Mon, 20 Jun 2016 18:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bF7lZ-0005O3-QI for bug-guile@gnu.org; Mon, 20 Jun 2016 18:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: taylanbayirli@gmail.com (Taylan Ulrich =?UTF-8?Q?Bay=C4=B1rl=C4=B1/Kammer?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 20 Jun 2016 22:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22447 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 22447-submit@debbugs.gnu.org id=B22447.146646204020698 (code B ref 22447); Mon, 20 Jun 2016 22:34:01 +0000 Original-Received: (at 22447) by debbugs.gnu.org; 20 Jun 2016 22:34:00 +0000 Original-Received: from localhost ([127.0.0.1]:48140 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bF7lY-0005Nm-42 for submit@debbugs.gnu.org; Mon, 20 Jun 2016 18:34:00 -0400 Original-Received: from mail-lf0-f51.google.com ([209.85.215.51]:35064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bF7lV-0005NY-Sl for 22447@debbugs.gnu.org; Mon, 20 Jun 2016 18:33:58 -0400 Original-Received: by mail-lf0-f51.google.com with SMTP id l188so49330892lfe.2 for <22447@debbugs.gnu.org>; Mon, 20 Jun 2016 15:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YghMBwDR5o6ul82Ln9K0u/eLjD8svUnTUu+ZZDdVsUI=; b=jdZPwpYWwFRD0SyS9mkW+sfpd9g+mTvcuYNXf7TmYOtdQiZ8fRei9PYHUfNiPwN7fg sIIJOeIrlQEfluk59doyB7isp5tpM+Vp5mgqo8Az4re+NTp9d7dGDr3/2xChbM+Whkhb 0ZggXws5Fb5tc9kK3ZdinsdvKipd8fKfNNvzx5kXYUCMBVSQnM1Yf5pnBfRJbUrHr1Hh rGavE0FtGQRmMJ8KA8hT1tz44/rbPlOtlnjqoSMGa144/8GfYNJ3lfjlw5+gIqmlmb4G +jSEGfsjUDBW48UcQahd/S80mre6n6pHaQysHFMCmfCl8AXdse67JXvgr1HGqKb2JiLE XtGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=YghMBwDR5o6ul82Ln9K0u/eLjD8svUnTUu+ZZDdVsUI=; b=fQAPM3FfXd4I6UcPCzoeOzymCmWkfXWTPdq97T5OfH8l7BzsT7VdhTd5cP6ApmCnNv YVdr0lwvXSckEmSfJgewRphsmoe/IybVG3+0aIw82lzuJDNRuGHFnnp66QdMhHqZL8Hg CXaqg5UhYzNIrK9rjZFDsJr5/OJ0qUXZP3bQbvSjJNhUIVxrbKjT2NqamGVccZCT71TN i6GRtpQwberPCzsamSNJ+goyC3wMTWZe4iWevJpqYMeSowh4j8LsnP4Rl+c5mwiXEMn6 3y2YisCVDJDhOdAx4P5c5uAsCScZZUTbqoELgJ7lxfHHtz+3bnCRkMd+LSsQqOoXt9Dx VijQ== X-Gm-Message-State: ALyK8tJ/9PeMqY4UPgc1Oybwec1w+vtP39j6RVWsAt2oyC2l3rn0l5UG4jUaBOLk4jbeDw== X-Received: by 10.28.27.8 with SMTP id b8mr236609wmb.40.1466462031780; Mon, 20 Jun 2016 15:33:51 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c30:3540:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id bh4sm35704219wjc.43.2016.06.20.15.33.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 15:33:50 -0700 (PDT) In-Reply-To: <87h9i3jj5y.fsf@T420.taylan> ("Taylan Ulrich \=\?utf-8\?Q\?\=5C\=22Bay\=C4\=B1rl\=C4\=B1\=2FKammer\=5C\=22\=22's\?\= message of "Sun, 24 Jan 2016 12:44:57 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8050 Archived-At: --=-=-= Content-Type: text/plain Pinging this thread with a (very slightly) updated patch. :-) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Hashtable-set-errors-on-immutable-hashtable.patch >From 7f35d515d711e255bba5a89a013d9d92034edf41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?= 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 --=-=-=--