Revert "instance_eval for classes and modules should behave as class_eval."

This reverts commit ee3017496b.

I misunderstood something and the new behavior was different from CRuby.
The issue was reported by @dearblue, regarding #5478
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-06-17 07:54:54 +09:00
parent 7893cbb523
commit a528834df7
+1 -11
View File
@@ -792,21 +792,11 @@ mrb_value
mrb_obj_instance_eval(mrb_state *mrb, mrb_value self)
{
mrb_value a, b;
struct RClass *c;
if (mrb_get_args(mrb, "|S&", &a, &b) == 1) {
mrb_raise(mrb, E_NOTIMP_ERROR, "instance_eval with string not implemented");
}
switch (mrb_type(self)) {
case MRB_TT_MODULE:
case MRB_TT_CLASS:
case MRB_TT_ICLASS:
c = mrb_class_ptr(self);
break;
default:
c = mrb_singleton_class_ptr(mrb, self);
}
return eval_under(mrb, self, b, c);
return eval_under(mrb, self, b, mrb_singleton_class_ptr(mrb, self));
}
MRB_API mrb_value