diff --git a/ChangeLog b/ChangeLog index 017faccb00..3109a5a8d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Mar 17 17:42:13 2005 Yukihiro Matsumoto + + * struct.c (make_struct): allow non local-id field + names. [ruby-core:04575] + + * struct.c (inspect_struct): ditto. + Wed Mar 16 23:39:13 2005 Shugo Maeda * test/ruby/test_settracefunc.rb: added test for c-return. diff --git a/parse.y b/parse.y index e91be7147b..4922eeee5e 100644 --- a/parse.y +++ b/parse.y @@ -8942,4 +8942,3 @@ Init_ripper() rb_intern("&&"); } #endif /* RIPPER */ - diff --git a/struct.c b/struct.c index 497de270ee..e94659d85d 100644 --- a/struct.c +++ b/struct.c @@ -210,17 +210,15 @@ make_struct(name, members, klass) rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0); for (i=0; i< RARRAY(members)->len; i++) { ID id = SYM2ID(RARRAY(members)->ptr[i]); - if (!rb_is_local_id(id)) { - rb_raise(rb_eNameError, "`%s' is not proper name for a struct member", - rb_id2name(id)); + if (rb_is_local_id(id)) { + if (ilen; i++) { - VALUE str2, slot; + VALUE slot; + ID id; char *p; if (i > 0) { rb_str_cat2(str, ", "); } slot = RARRAY(members)->ptr[i]; - p = rb_id2name(SYM2ID(slot)); - rb_str_cat2(str, p); + id = SYM2ID(slot); + if (rb_is_local_id(id)) { + p = rb_id2name(id); + rb_str_cat2(str, p); + } + else { + rb_str_append(str, rb_inspect(slot)); + } rb_str_cat2(str, "="); - str2 = rb_inspect(RSTRUCT(s)->ptr[i]); - rb_str_append(str, str2); + rb_str_append(str, rb_inspect(RSTRUCT(s)->ptr[i])); } rb_str_cat2(str, ">"); OBJ_INFECT(str, s);