ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95573] [Ruby master Bug#14325] Set#reset raise RuntimeError instead of FrozenError
Date: Sun, 27 Oct 2019 22:38:49 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-82355.20191027223848.54a07553312849b4@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-14325.20180106153205@ruby-lang.org

Issue #14325 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Assigned to Closed

Fixed in commit:afd68cd87114fb49158462f1594cacfd2b765e9b.

----------------------------------------
Bug #14325: Set#reset raise RuntimeError instead of FrozenError
https://bugs.ruby-lang.org/issues/14325#change-82355

* Author: znz (Kazuhiro NISHIYAMA)
* Status: Closed
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-01-06 trunk 61640) [x86_64-darwin16]
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: UNKNOWN
----------------------------------------
I think it should use `FrozenError` instead of `RuntimeError`.
I can't reproduce without modifying instance variable directly.

```
%  ruby -v -r set -e 'Set[].tap{|s|s.instance_variable_set(:@hash, :dummy)}.freeze.reset'
ruby 2.6.0dev (2018-01-06 trunk 61640) [x86_64-darwin16]
Traceback (most recent call last):
	1: from -e:1:in `<main>'
.../lib/ruby/2.6.0/set.rb:527:in `reset': can't modify frozen Set (RuntimeError)
%  ruby -v -I ./lib -r set -e 'Set[].tap{|s|s.instance_variable_set(:@hash, :dummy)}.freeze.reset'
ruby 2.6.0dev (2018-01-06 trunk 61640) [x86_64-darwin16]
Traceback (most recent call last):
	1: from -e:1:in `<main>'
.../lib/set.rb:527:in `reset': can't modify frozen Set (FrozenError)
```

```patch
diff --git a/lib/set.rb b/lib/set.rb
index 9642e74af4..d777b81b8f 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -524,7 +524,7 @@ def reset
     if @hash.respond_to?(:rehash)
       @hash.rehash # This should perform frozenness check.
     else
-      raise "can't modify frozen #{self.class.name}" if frozen?
+      raise FrozenError, "can't modify frozen #{self.class.name}" if frozen?
     end
     self
   end
```



-- 
https://bugs.ruby-lang.org/

      parent reply	other threads:[~2019-10-27 22:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-14325.20180106153205@ruby-lang.org>
2018-01-06 15:32 ` [ruby-core:84677] [Ruby trunk Bug#14325] Set#reset raise RuntimeError instead of FrozenError zn
2019-10-27 22:38 ` merch-redmine [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-82355.20191027223848.54a07553312849b4@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).