diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-08 14:47:19 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-08 14:47:19 +0000 |
commit | 1fd41dce10a93ce89a098ffc33f40d5243f5e140 (patch) | |
tree | 7745a5222f5606ca6dae897ef2ebec03db0234bd /variable.c | |
parent | f6a2a4311647d2dd4d90c012cc3128eac96e255b (diff) | |
download | ruby-1fd41dce10a93ce89a098ffc33f40d5243f5e140.tar.gz |
* variable.c (set_const_visibility): clear inine-cache when constant's
visibility is modified. [ruby-dev:44929]
* test/ruby/test_module.rb (test_private_constants_clear_inlinecache):
add test for it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/variable.c b/variable.c index 7f8988c579..0dec1aa285 100644 --- a/variable.c +++ b/variable.c @@ -2119,13 +2119,19 @@ set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag) VALUE val = argv[i]; id = rb_check_id(&val); if (!id) { + if ( i > 0 ) + rb_clear_cache_by_class(mod); rb_name_error_str(val, "constant %s::%s not defined", rb_class2name(mod), RSTRING_PTR(val)); } - if (RCLASS_CONST_TBL(mod) && st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) { + if (RCLASS_CONST_TBL(mod) && + st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) { ((rb_const_entry_t*)v)->flag = flag; - continue; } - rb_name_error(id, "constant %s::%s not defined", rb_class2name(mod), rb_id2name(id)); + else { + if ( i > 0 ) + rb_clear_cache_by_class(mod); + rb_name_error(id, "constant %s::%s not defined", rb_class2name(mod), rb_id2name(id)); + } } rb_clear_cache_by_class(mod); } |