From e782ca865b3353870fd0fe5f45709c4997366d1a Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 13 Feb 2012 04:51:21 +0000 Subject: merge revision(s) 33935,33936,33987: [Backport #5702] * variable.c (set_const_visibility): Module#private_constant has changed the visibility of only the first argument. Now it changes all of them. [ruby-list:48558] * test/ruby/test_module.rb: add a test for above. * variable.c (set_const_visibility): print a warning when no argument is passwd to Module#private_constant. [ruby-list:48558] * vm_method.c (set_method_visibility): ditto for Module#private_class_method. * 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/branches/ruby_1_9_3@34579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index ed6f3debd9..caadf71909 100644 --- a/variable.c +++ b/variable.c @@ -1952,13 +1952,22 @@ set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag) "Insecure: can't change constant visibility"); } + if (argc == 0) { + rb_warning("%s with no argument is just ignored", rb_id2name(rb_frame_callee())); + } + for (i = 0; i < argc; i++) { - id = rb_to_id(argv[i]); - if (RCLASS_CONST_TBL(mod) && st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) { + VALUE val = argv[i]; + id = rb_to_id(val); + if (RCLASS_CONST_TBL(mod) && + st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) { ((rb_const_entry_t*)v)->flag = flag; - return; } - 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