Hello,
Key cannot be found in a Hash when slice! method is applied to the key. I cannot reproduce this behaviour with sub! or gsub! methods:
hash={}key="ABC OÜ"key.slice!(/ oü$/i)# key.sub!(/ oü$/i, '')# key.gsub!(/ oü$/i, '')hash[key]=true"#{key} in #{hash}: value is #{hash[key]}"=>"ABC in {\"ABC\"=>true}: value is "
Also it seems that ruby 2.7.6 and 3.2.2 don't have this issue.
The two strings are identical (aside from one being frozen):
require"objspace"hash={}key="ABC OÜ"pkey.hashkey.slice!(/ oü$/i)pkey.hashputsObjectSpace.dump(key)hash[key]=truep"#{key} in #{hash}: value is #{hash[key].inspect}"putsObjectSpace.dump(hash.keys.first)p[hash.keys.first,key,hash.keys.first==key]p[hash.keys.first.hash,key.hash]
I had a quick look at recent changes in String#slice! that could explain why it's fixed in 3.2, but didn't spot anything yet.
What is interesting though is that the first access to key.hash returns -2878200511277543492, but then later it consistently returns -2878200511277543491. I wonder if there is an off by one bug somewhere.