More details `Set.new`
Since the implementation of Set is Hash, the key must have a hash method.
$ ruby -e 'Set.new([BasicObject.new])'
/Users/ksss/.rbenv/versions/3.3.0/lib/ruby/3.3.0/set.rb:509:in `add': undefined method `hash' for an instance of BasicObject (NoMethodError)
@hash[o] = true
^^^^^
The type argument A for Set should strictly be A < Hash::_Key. However, making this change would break compatibility, so it cannot be done.
In practice, using BasicObject is rare, so there is no need to make this change.
@ksss
The type argument
Afor Set should strictly beA < Hash::_Key. However, making this change would break compatibility, so it cannot be done.
I'm fan of making the type parameter bounded, A < Hash::_Key. Did you see any specific compatibility problem with it?
For Set only json has been found, but I have the following concern.
- Only ruby/rbs and ruby/gem_rbs_collection were checked, and I am not sure if they are also completely absent in the sig directory distributed in the rubygems.
- The same issue exists with
Hash, which is used in activesupport.
This PR has resolved by https://github.com/ruby/rbs/pull/1810