block_given? should return false on top-level; ref #2678

This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-12-19 18:51:14 +09:00
parent 2732879f3e
commit 5014bfb50d
+3
View File
@@ -189,6 +189,9 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self)
if (ci->proc->env && ci->proc->env->stack) {
mrb_value *sp = ci->proc->env->stack;
/* top-level does not have block slot (alway false) */
if (sp == mrb->c->stbase)
return mrb_false_value();
while (mrb->c->cibase < ci) {
if (ci->stackent == sp) {
break;