aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-13 13:18:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-13 13:18:35 +0000
commit283189807cc0f384fa235de7f70a1536d830aff7 (patch)
tree78f250b6274729937cddcda0515222ee24db6e44 /variable.c
parent476a0355db8eb2e80dfd0cae6fcfd9c0a4490409 (diff)
downloadruby-283189807cc0f384fa235de7f70a1536d830aff7.tar.gz
* variable.c (rb_mod_remove_const): do not change VM state when an
exception will occur. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/variable.c b/variable.c
index ea7dfbb0da..4b73b5c0be 100644
--- a/variable.c
+++ b/variable.c
@@ -1596,8 +1596,6 @@ rb_mod_remove_const(VALUE mod, VALUE name)
VALUE val;
st_data_t v, n = id;
- rb_vm_change_state();
-
if (!rb_is_const_id(id)) {
rb_name_error(id, "`%s' is not allowed as a constant name", rb_id2name(id));
}
@@ -1605,21 +1603,23 @@ rb_mod_remove_const(VALUE mod, VALUE name)
rb_raise(rb_eSecurityError, "Insecure: can't remove constant");
if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
- if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &v)) {
- val = (VALUE)v;
- if (val == Qundef) {
- autoload_delete(mod, id);
- val = Qnil;
+ if (!RCLASS_IV_TBL(mod) || !st_delete(RCLASS_IV_TBL(mod), &n, &v)) {
+ if (rb_const_defined_at(mod, id)) {
+ rb_name_error(id, "cannot remove %s::%s",
+ rb_class2name(mod), rb_id2name(id));
}
- return val;
+ rb_name_error(id, "constant %s::%s not defined",
+ rb_class2name(mod), rb_id2name(id));
}
- if (rb_const_defined_at(mod, id)) {
- rb_name_error(id, "cannot remove %s::%s",
- rb_class2name(mod), rb_id2name(id));
+
+ rb_vm_change_state();
+
+ val = (VALUE)v;
+ if (val == Qundef) {
+ autoload_delete(mod, id);
+ val = Qnil;
}
- rb_name_error(id, "constant %s::%s not defined",
- rb_class2name(mod), rb_id2name(id));
- return Qnil; /* not reached */
+ return val;
}
static int