なかだです。

  $ ruby -e X = Class.new; p X.name'
  ""

  $ ruby -e X = Class.new; X.inspect; p X.name'
  "X"

となります。1.6ではどちらも"X"です。

おそらくruby-bug-ja:PR#424の副作用のようですが。


Index: variable.c =================================================================== RCS file: //sharui/cvs/ruby/src/ruby/variable.c,v retrieving revision 1.93 diff -u -2 -p -r1.93 variable.c --- variable.c 3 Jul 2003 11:00:18 -0000 1.93 +++ variable.c 3 Jul 2003 13:10:17 -0000 @@ -21,5 +21,5 @@ static st_table *rb_global_tbl; st_table *rb_class_tbl; -static ID autoload; +static ID autoload, classpath, tmp_classpath; void @@ -29,4 +29,6 @@ Init_var_tables() rb_class_tbl = st_init_numtable(); autoload = rb_intern("__autoload__"); + classpath = rb_intern("__classpath__"); + tmp_classpath = rb_intern("__tmp_classpath__"); } @@ -50,5 +52,5 @@ fc_path(fc, name) if (fc->track == rb_cObject) break; if (ROBJECT(fc->track)->iv_tbl && - st_lookup(ROBJECT(fc->track)->iv_tbl, rb_intern("__classpath__"), &tmp)) { + st_lookup(ROBJECT(fc->track)->iv_tbl, classpath, &tmp)) { tmp = rb_str_dup(tmp); rb_str_cat2(tmp, "::"); @@ -132,5 +134,5 @@ find_class_path(klass) ROBJECT(klass)->iv_tbl = st_init_numtable(); } - st_insert(ROBJECT(klass)->iv_tbl,rb_intern("__classpath__"),arg.path); + st_insert(ROBJECT(klass)->iv_tbl, classpath, arg.path); return arg.path; } @@ -143,5 +145,5 @@ classname(klass) { VALUE path = Qnil; - ID classpath = rb_intern("__classpath__"); + ID tmppath = tmp_classpath; klass = rb_class_real(klass); @@ -152,5 +154,5 @@ classname(klass) if (!st_lookup(ROBJECT(klass)->iv_tbl, classid, &path)) { - return Qnil; + return find_class_path(klass); } path = rb_str_new2(rb_id2name(SYM2ID(path))); @@ -163,5 +165,5 @@ classname(klass) return path; } - return Qnil; + return find_class_path(klass); } @@ -184,12 +186,7 @@ rb_class_path(klass) if (!NIL_P(path)) return path; else { - ID tmppath = rb_intern("__tmp_classpath__"); + ID tmppath = tmp_classpath; char *s = "Class"; - path = find_class_path(klass); - if (!NIL_P(path)) { - st_delete(RCLASS(klass)->iv_tbl, &tmppath, 0); - return path; - } if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, tmppath, &path)) { return path; @@ -207,5 +204,5 @@ rb_class_path(klass) sprintf(RSTRING(path)->ptr, "#<%s:0x%lx>", s, klass); RSTRING(path)->len = strlen(RSTRING(path)->ptr); - rb_iv_set(klass, "__tmp_classpath__", path); + rb_ivar_set(klass, tmp_classpath, path); return path; @@ -228,5 +225,5 @@ rb_set_class_path(klass, under, name) rb_str_cat2(str, name); } - rb_iv_set(klass, "__classpath__", str); + rb_ivar_set(klass, classpath, str); }
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦