summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-03 09:00:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-03 09:00:52 +0000
commitc29e1b147e52ad81554d94a422210f1c1ff97d9e (patch)
treeb169cc7c3b4f2dd17e6a0d768ba75e1a982632bd /struct.c
parente5ff3095ddac2d15b49b8beb24d412d167d7f053 (diff)
downloadruby-c29e1b147e52ad81554d94a422210f1c1ff97d9e.tar.gz
ruby-c29e1b147e52ad81554d94a422210f1c1ff97d9e.tar.xz
ruby-c29e1b147e52ad81554d94a422210f1c1ff97d9e.zip
* struct.c (make_struct): remove redefining constant when
conflict. [ruby-dev:24210] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/struct.c b/struct.c
index 900f8bdbf..4fab88fc0 100644
--- a/struct.c
+++ b/struct.c
@@ -177,6 +177,10 @@ make_struct(name, member, klass)
if (!rb_is_const_id(id)) {
rb_name_error(id, "identifier %s needs to be constant", cname);
}
+ if (rb_const_defined_at(klass, id)) {
+ rb_warn("redefining constant Struct::%s", cname);
+ rb_mod_remove_const(klass, ID2SYM(id));
+ }
nstr = rb_define_class_under(klass, cname, klass);
}
rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY(member)->len));