Skip to content

Commit 5e6ea6c

Browse files
committed
vm.c: restore visibility when reopen class/module definition
Ideally, the default visibility should be stored in the scope. But for the time being mruby stores the visibility in the class/module. As a result, nesting class/module reopening or class_eval/module_eval could cause incompatibility. We will try to fix them in the future.
1 parent 2a876d2 commit 5e6ea6c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/vm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ mrb_mod_module_eval(mrb_state *mrb, mrb_value mod)
10111011
if (mrb_get_args(mrb, "|S&", &a, &b) == 1) {
10121012
mrb_raise(mrb, E_NOTIMP_ERROR, "module_eval/class_eval with string not implemented");
10131013
}
1014+
MRB_SET_VISIBILITY(mrb_class_ptr(mod), MRB_METHOD_PUBLIC_FL);
10141015
return eval_under(mrb, mod, b, mrb_class_ptr(mod));
10151016
}
10161017

@@ -2940,6 +2941,9 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *begin_proc, const mrb_code *iseq
29402941
struct RClass *c = mrb_class_ptr(recv);
29412942
const mrb_irep *nirep = irep->reps[b];
29422943

2944+
/* restore visibility */
2945+
MRB_SET_VISIBILITY(c, MRB_METHOD_PUBLIC_FL);
2946+
29432947
/* prepare closure */
29442948
struct RProc *p = mrb_proc_new(mrb, nirep);
29452949
p->c = NULL;

0 commit comments

Comments
 (0)