Project

General

Profile

Bug #16826

ObjectSpace::WeakMap#key? returns false if value is nil

Added by Eregon (Benoit Daloze) 3 months ago. Updated 12 days ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
[ruby-core:98118]

Description

$ ruby -e 'map=ObjectSpace::WeakMap.new; map[:foo] = 4; p map; p map.key? :foo'  
#<ObjectSpace::WeakMap:0x000055fbe0c38c00: :foo => 4>
true # OK

$ ruby -e 'map=ObjectSpace::WeakMap.new; map[:foo] = nil; p map; p map.key? :foo'
#<ObjectSpace::WeakMap:0x000056371e3f86e8: :foo => nil>
false # BUG

Updated by Eregon (Benoit Daloze) 3 months ago

  • Assignee set to Eregon (Benoit Daloze)

I'll fix this.

#2

Updated by Eregon (Benoit Daloze) 3 months ago

  • Status changed from Open to Closed

Applied in changeset git|a2be428c5fec31b8adbd5ac087e7637ddf7e54d0.


Fix ObjectSpace::WeakMap#key? to work if the value is nil

Updated by nagachika (Tomoyuki Chikanaga) 12 days ago

  • Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE

ruby_2_7 9da6470d7b3aa136b4b92469c8bbc522beb1ac31 merged revision(s) a2be428c5fec31b8adbd5ac087e7637ddf7e54d0.

Also available in: Atom PDF