ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:84677] [Ruby trunk Bug#14325] Set#reset raise RuntimeError instead of FrozenError
       [not found] <redmine.issue-14325.20180106153205@ruby-lang.org>
@ 2018-01-06 15:32 ` zn
  2019-10-27 22:38 ` [ruby-core:95573] [Ruby master " merch-redmine
  1 sibling, 0 replies; 2+ messages in thread
From: zn @ 2018-01-06 15:32 UTC (permalink / raw)
  To: ruby-core

Issue #14325 has been reported by znz (Kazuhiro NISHIYAMA).

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

* Author: znz (Kazuhiro NISHIYAMA)
* Status: Assigned
* 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/

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

* [ruby-core:95573] [Ruby master Bug#14325] Set#reset raise RuntimeError instead of FrozenError
       [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
  1 sibling, 0 replies; 2+ messages in thread
From: merch-redmine @ 2019-10-27 22:38 UTC (permalink / raw)
  To: ruby-core

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/

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

end of thread, other threads:[~2019-10-27 22:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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 ` [ruby-core:95573] [Ruby master " merch-redmine

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).