mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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.
This commit is contained in:
@@ -1011,6 +1011,7 @@ mrb_mod_module_eval(mrb_state *mrb, mrb_value mod)
|
||||
if (mrb_get_args(mrb, "|S&", &a, &b) == 1) {
|
||||
mrb_raise(mrb, E_NOTIMP_ERROR, "module_eval/class_eval with string not implemented");
|
||||
}
|
||||
MRB_SET_VISIBILITY(mrb_class_ptr(mod), MRB_METHOD_PUBLIC_FL);
|
||||
return eval_under(mrb, mod, b, mrb_class_ptr(mod));
|
||||
}
|
||||
|
||||
@@ -2940,6 +2941,9 @@ RETRY_TRY_BLOCK:
|
||||
struct RClass *c = mrb_class_ptr(recv);
|
||||
const mrb_irep *nirep = irep->reps[b];
|
||||
|
||||
/* restore visibility */
|
||||
MRB_SET_VISIBILITY(c, MRB_METHOD_PUBLIC_FL);
|
||||
|
||||
/* prepare closure */
|
||||
struct RProc *p = mrb_proc_new(mrb, nirep);
|
||||
p->c = NULL;
|
||||
|
||||
Reference in New Issue
Block a user