summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-29 09:08:18 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-29 09:08:18 +0000
commit40bc4f5ae4ffe325c36a49e0d3280dbee2a39cee (patch)
tree834cc2146161802fb97d89f0a747ae794048169b /eval.c
parent3bf972993f689965c857540ec1ccc729477e8e66 (diff)
* array.c (rb_ary_become): should not free ptr if it's shared.
* eval.c (rb_alias): prohibit making an alias named "allocate" if klass is a metaclass. * string.c (rb_string_value_ptr): StringValuePtr() should never return NULL pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index 425ee5a..25ce389 100644
--- a/eval.c
+++ b/eval.c
@@ -1700,6 +1700,7 @@ rb_alias(klass, name, def)
{
VALUE origin;
NODE *orig, *body;
+ VALUE singleton = 0;
rb_frozen_class_p(klass);
if (name == def) return;
@@ -1715,6 +1716,12 @@ rb_alias(klass, name, def)
if (!orig || !orig->nd_body) {
print_undef(klass, def);
}
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ singleton = rb_iv_get(klass, "__attached__");
+ if (name == alloc && TYPE(singleton) == T_CLASS) {
+ rb_raise(rb_eNameError, "cannot make alias named `allocate'");
+ }
+ }
body = orig->nd_body;
orig->nd_cnt++;
if (nd_type(body) == NODE_FBODY) { /* was alias */
@@ -1726,9 +1733,8 @@ rb_alias(klass, name, def)
rb_clear_cache_by_id(name);
st_insert(RCLASS(klass)->m_tbl, name,
NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_funcall(rb_iv_get(klass, "__attached__"),
- singleton_added, 1, ID2SYM(name));
+ if (singleton) {
+ rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
}
else {
rb_funcall(klass, added, 1, ID2SYM(name));