summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-20 05:55:38 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-20 05:55:38 +0000
commit5a1e96b22aa6759bde56ff9667759b44e9f6fa28 (patch)
tree956063703940ef9f3d450768628584dc08f97c42 /variable.c
parent4c97b921f2f6d71d7a3f2c0b2c0c089b15686973 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/variable.c b/variable.c
index ef4b49e60d..d676995450 100644
--- a/variable.c
+++ b/variable.c
@@ -786,10 +786,10 @@ VALUE
obj_remove_instance_variable(obj, name)
VALUE obj, name;
{
- VALUE val;
+ VALUE val = Qnil;
ID id = rb_to_id(name);
- if (rb_ivar_defined(obj, id)) {
+ if (!rb_is_instance_id(id)) {
NameError("`%s' is not an instance variable", rb_id2name(id));
}
@@ -806,7 +806,7 @@ obj_remove_instance_variable(obj, name)
rb_class2name(CLASS_OF(obj)));
break;
}
- return obj;
+ return val;
}
VALUE
@@ -889,6 +889,28 @@ const_i(key, value, ary)
return ST_CONTINUE;
}
+VALUE
+mod_remove_const(mod, name)
+ VALUE mod, name;
+{
+ ID id = rb_to_id(name);
+ VALUE val;
+
+ if (!rb_is_const_id(id)) {
+ NameError("`%s' is not constant", rb_id2name(id));
+ }
+
+ if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, &id, &val)) {
+ return val;
+ }
+ if (rb_const_defined_at(mod, id)) {
+ NameError("cannot remove %s::%s",
+ rb_class2name(mod), rb_id2name(id));
+ }
+ NameError("constant %s::%s not defined",
+ rb_class2name(mod), rb_id2name(id));
+}
+
static int
autoload_i(key, name, ary)
ID key;