diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-05-11 01:11:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-05-11 01:11:52 +0000 |
commit | 1843d8abbc62f0b148c6b05ee0091619bfd5e332 (patch) | |
tree | 770c6375aa95afadfa812ed9f28a937221f8e2f0 /eval.c | |
parent | 7efdc82d2ef523baf7548039e5f76420a83d6795 (diff) |
* struct.c (make_struct): allow const_id for accessor names.
[ruby-core:04585]
* eval.c (rb_attr): check if attribute name is local_id or
const_id.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -622,6 +622,9 @@ rb_attr(klass, id, read, write, ex) } } + if (!rb_is_local_id(id) && !rb_is_const_id(id)) { + rb_name_error(id, "invalid attribute name `%s'", rb_id2name(id)); + } name = rb_id2name(id); if (!name) { rb_raise(rb_eArgError, "argument needs to be symbol or string"); @@ -633,9 +636,7 @@ rb_attr(klass, id, read, write, ex) rb_add_method(klass, id, NEW_IVAR(attriv), noex); } if (write) { - sprintf(buf, "%s=", name); - id = rb_intern(buf); - rb_add_method(klass, id, NEW_ATTRSET(attriv), noex); + rb_add_method(klass, rb_id_attrset(id), NEW_ATTRSET(attriv), noex); } } |