mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* 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
This commit is contained in:
parent
3e0819c66a
commit
bc2a1f2a98
7 changed files with 40 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue