summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index e6a927b21f..990aa5da47 100644
--- a/eval.c
+++ b/eval.c
@@ -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);
}
}