Skip to content

Commit a7f3cfb

Browse files
committed
hash.c: allow 'default_proc=nil' to clear default_proc; ref mruby#6483
1 parent 837f62f commit a7f3cfb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/hash.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,9 @@ mrb_hash_set_default_proc(mrb_state *mrb, mrb_value hash)
14771477
mrb_value ifnone = mrb_get_arg1(mrb);
14781478

14791479
hash_modify(mrb, hash);
1480-
mrb_check_type(mrb, ifnone, MRB_TT_PROC);
1480+
if (!mrb_nil_p(ifnone)) {
1481+
mrb_check_type(mrb, ifnone, MRB_TT_PROC);
1482+
}
14811483
mrb_iv_set(mrb, hash, MRB_SYM(ifnone), ifnone);
14821484
if (!mrb_nil_p(ifnone)) {
14831485
RHASH(hash)->flags |= MRB_HASH_PROC_DEFAULT;

0 commit comments

Comments
 (0)