mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
singleton_class should not be cloned; close #2815
This commit is contained in:
@@ -330,6 +330,9 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
|
||||
if (mrb_immediate_p(self)) {
|
||||
mrb_raisef(mrb, E_TYPE_ERROR, "can't clone %S", self);
|
||||
}
|
||||
if (mrb_type(self) == MRB_TT_SCLASS) {
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "can't clone singleton class");
|
||||
}
|
||||
p = (struct RObject*)mrb_obj_alloc(mrb, mrb_type(self), mrb_obj_class(mrb, self));
|
||||
p->c = mrb_singleton_class_clone(mrb, self);
|
||||
clone = mrb_obj_value(p);
|
||||
|
||||
Reference in New Issue
Block a user