Skip to content

Commit 2ad3f0e

Browse files
committed
vm.c (mrb_yield_with_class): keep mid of the callee
Otherwise `super` from within blocks may call wrong methods.
1 parent 9040baa commit 2ad3f0e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/vm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ MRB_API mrb_value
976976
mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c)
977977
{
978978
struct RProc *p;
979-
mrb_sym mid = mrb->c->ci->mid;
979+
mrb_sym mid;
980980
mrb_callinfo *ci;
981981
mrb_value val;
982982
mrb_int n;
@@ -985,6 +985,12 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
985985
ci = mrb->c->ci;
986986
n = mrb_ci_nregs(ci);
987987
p = mrb_proc_ptr(b);
988+
if (MRB_PROC_ENV_P(p)) {
989+
mid = p->e.env->mid;
990+
}
991+
else {
992+
mid = ci->mid;
993+
}
988994
ci = cipush(mrb, n, CINFO_DIRECT, NULL, NULL, NULL, mid, 0);
989995
funcall_args_capture(mrb, 0, argc, argv, mrb_nil_value(), ci);
990996
ci->u.target_class = c;

0 commit comments

Comments
 (0)