From 1fd41dce10a93ce89a098ffc33f40d5243f5e140 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 8 Dec 2011 14:47:19 +0000 Subject: * 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 --- variable.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'variable.c') 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); } -- cgit v1.2.3