Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block_given? always returns false when it calls in block #2703

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,10 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self)
given_p = FALSE;
}
else {
/* block_given? called within block; check upper scope */
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();
ci = mrb->c->cibase + ci->proc->env->cioff;
bp = ci[1].stackent + 1;
/* If block_given? is called within block, it always returns false. */
if (ci->proc->env && ci->proc->env->stack) {
return mrb_false_value();
}
if (ci->argc > 0) {
bp += ci->argc;
Expand Down