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/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>