From a1db5ecd935ef1fc95ad8844f33f293fe22bfdf5 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 14 Apr 2023 11:28:41 +0200 Subject: Add specs for ObjectSpace::WeakKeyMap [Feature #18498] --- weakmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'weakmap.c') diff --git a/weakmap.c b/weakmap.c index 8629d77ffb..f5b9a5fbf4 100644 --- a/weakmap.c +++ b/weakmap.c @@ -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); -- cgit v1.2.1