Project

General

Profile

Actions

Bug #16826

closed

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

Added by Eregon (Benoit Daloze) almost 4 years ago. Updated over 3 years ago.

Status:
Closed
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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0