Issue #9223 has been updated by nagachika (Tomoyuki Chikanaga).

Status changed from Closed to Assigned
Assignee set to matz (Yukihiro Matsumoto)

Hello,

r44137 introduce incompatible spec change of Hash#reject.
After r44137, Hash#reject return new hash and doesn't copied class, ivars, default value, taintedness from receiver.
ChangeLog says 'they had been copied just by accident.'
Even if it is the truth, hsh.reject is equivalent to hsh.dup.reject! for very long time and it is documented explicitly. There's a such description since ruby 1.8.1.
https://github.com/ruby/ruby/blob/v1_8_1/hash.c#L734

I think this change needs approval by matz, or at least by 2.1 release manager (naruse san).
----------------------------------------
Bug #9223: Hash#reject!.size does not reflect changes to the hash
https://bugs.ruby-lang.org/issues/9223#change-43622

Author: dmarcotte (Daniel Marcotte)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 
ruby -v: ruby 2.0.0p353
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


Here's an example demonstrating the issue, comparing to the regular reject behavior:  

h = {a: 'A', b: 'B'}
reject_enum = h.reject
reject_bang_enum = h.reject!
h[:c] = 'C'
p reject_enum.size # 3
p reject_bang_enum.size # 2



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