diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-03 15:11:53 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-03 15:11:53 +0000 |
commit | bc2a1f2a98b04f040ea485cedd3283f2f3906e4c (patch) | |
tree | 833ab2f599dfd7576201ab5745e7ffeb5436fd88 /variable.c | |
parent | 3e0819c66a0908be61fbb769e96c1accb1d67f26 (diff) |
* variable.c (rb_const_set): show the previous definition
location. [EXPERIMENTAL]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/variable.c b/variable.c index 9526b6226f..3909b799c4 100644 --- a/variable.c +++ b/variable.c @@ -2057,8 +2057,13 @@ rb_const_set(VALUE klass, ID id, VALUE val) autoload_delete(klass, id); } else { + const char *name = rb_id2name(id); visibility = ce->flag; - rb_warn("already initialized constant %s", rb_id2name(id)); + rb_warn("already initialized constant %s", name); + if (!NIL_P(ce->file) && ce->line) { + rb_compile_warn(RSTRING_PTR(ce->file), ce->line, + "previous definition of %s was here", name); + } } } } @@ -2068,6 +2073,8 @@ rb_const_set(VALUE klass, ID id, VALUE val) ce = ALLOC(rb_const_entry_t); ce->flag = (rb_const_flag_t)visibility; ce->value = val; + ce->file = rb_sourcefilename(); + ce->line = rb_sourceline(); st_insert(RCLASS_CONST_TBL(klass), (st_data_t)id, (st_data_t)ce); } |