Add specs for ObjectSpace::WeakKeyMap

[Feature #18498]
This commit is contained in:
Jean Boussier 2023-04-14 11:28:41 +02:00 committed by Jean Boussier
parent 45c6b58768
commit a1db5ecd93
Notes: git 2023-04-15 00:11:07 +00:00
6 changed files with 163 additions and 1 deletions

View file

@ -727,8 +727,9 @@ wkmap_aset(VALUE self, VALUE key, VALUE value)
struct weakkeymap *w;
TypedData_Get_Struct(self, struct weakkeymap, &weakkeymap_type, w);
if (!(FL_ABLE(key) && !SYMBOL_P(key) && !RB_BIGNUM_TYPE_P(key))) {
if (!FL_ABLE(key) || SYMBOL_P(key) || RB_BIGNUM_TYPE_P(key) || RB_TYPE_P(key, T_FLOAT)) {
rb_raise(rb_eArgError, "WeakKeyMap must be garbage collectable");
UNREACHABLE_RETURN(Qnil);
}
st_index_t hash = wkmap_lookup_hash(w, key);