hash.c: allow 'default_proc=nil' to clear default_proc; ref #6483

This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-03-08 15:49:26 +09:00
parent 837f62f18a
commit a7f3cfb711
+3 -1
View File
@@ -1477,7 +1477,9 @@ mrb_hash_set_default_proc(mrb_state *mrb, mrb_value hash)
mrb_value ifnone = mrb_get_arg1(mrb);
hash_modify(mrb, hash);
mrb_check_type(mrb, ifnone, MRB_TT_PROC);
if (!mrb_nil_p(ifnone)) {
mrb_check_type(mrb, ifnone, MRB_TT_PROC);
}
mrb_iv_set(mrb, hash, MRB_SYM(ifnone), ifnone);
if (!mrb_nil_p(ifnone)) {
RHASH(hash)->flags |= MRB_HASH_PROC_DEFAULT;