Commit 5e6cd86f authored by dearblue's avatar dearblue

Fix to not define outer when outer is itself.

example:
  a = Class.new
  a::A = a
parent 1997fcf9
......@@ -65,7 +65,7 @@ mrb_class_name_class(mrb_state *mrb, struct RClass *outer, struct RClass *c, mrb
else {
name = mrb_class_path(mrb, outer);
if (mrb_nil_p(name)) { /* unnamed outer class */
if (outer != mrb->object_class) {
if (outer != mrb->object_class && outer != c) {
mrb_obj_iv_set(mrb, (struct RObject*)c, mrb_intern_lit(mrb, "__outer__"),
mrb_obj_value(outer));
}
......
......@@ -377,8 +377,9 @@ is_namespace(enum mrb_vtype tt)
static inline void
assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
{
if (is_namespace(obj->tt) && is_namespace(mrb_type(v)) && ISUPPER(mrb_sym2name(mrb, sym)[0])) {
if (is_namespace(obj->tt) && is_namespace(mrb_type(v))) {
struct RObject *c = mrb_obj_ptr(v);
if (obj != c && ISUPPER(mrb_sym2name(mrb, sym)[0])) {
mrb_sym id_classname = mrb_intern_lit(mrb, "__classname__");
mrb_value o = mrb_obj_iv_get(mrb, c, id_classname);
......@@ -396,6 +397,7 @@ assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
}
}
}
}
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment