ruby-changes:22500
From: naruse <ko1@a...>
Date: Sat, 11 Feb 2012 06:33:33 +0900 (JST)
Subject: [ruby-changes:22500] naruse:r34549 (ruby_1_9_3): Revert r34538.
naruse 2012-02-11 06:32:02 +0900 (Sat, 11 Feb 2012) New Revision: 34549 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34549 Log: Revert r34538. * backport 33935,33936,33987 (fix private constant) Modified files: branches/ruby_1_9_3/test/ruby/test_module.rb branches/ruby_1_9_3/variable.c branches/ruby_1_9_3/vm_method.c Index: ruby_1_9_3/variable.c =================================================================== --- ruby_1_9_3/variable.c (revision 34548) +++ ruby_1_9_3/variable.c (revision 34549) @@ -1952,22 +1952,13 @@ "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++) { - 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)) { + id = rb_to_id(argv[i]); + if (RCLASS_CONST_TBL(mod) && st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) { ((rb_const_entry_t*)v)->flag = flag; + return; } - 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_name_error(id, "constant %s::%s not defined", rb_class2name(mod), rb_id2name(id)); } rb_clear_cache_by_class(mod); } Index: ruby_1_9_3/vm_method.c =================================================================== --- ruby_1_9_3/vm_method.c (revision 34548) +++ ruby_1_9_3/vm_method.c (revision 34549) @@ -961,11 +961,6 @@ { int i; secure_visibility(self); - - if (argc == 0) { - rb_warning("%s with no argument is just ignored", rb_id2name(rb_frame_callee())); - } - for (i = 0; i < argc; i++) { rb_export_method(self, rb_to_id(argv[i]), ex); } Index: ruby_1_9_3/test/ruby/test_module.rb =================================================================== --- ruby_1_9_3/test/ruby/test_module.rb (revision 34548) +++ ruby_1_9_3/test/ruby/test_module.rb (revision 34549) @@ -1019,19 +1019,6 @@ assert_raise(NameError) { c::FOO } end - def test_private_constant2 - c = Class.new - c.const_set(:FOO, "foo") - c.const_set(:BAR, "bar") - assert_equal("foo", c::FOO) - assert_equal("bar", c::BAR) - c.private_constant(:FOO, :BAR) - assert_raise(NameError) { c::FOO } - assert_raise(NameError) { c::BAR } - assert_equal("foo", c.class_eval("FOO")) - assert_equal("bar", c.class_eval("BAR")) - end - class PrivateClass end private_constant :PrivateClass @@ -1079,27 +1066,6 @@ assert_in_out_err([], src, %w(Object :ok), []) end - def test_private_constants_clear_inlinecache - bug5702 = '[ruby-dev:44929]' - src = <<-INPUT - class A - C = :Const - def self.get_C - A::C - end - # fill cache - A.get_C - private_constant :C, :D rescue nil - begin - A.get_C - rescue NameError - puts "A.get_C" - end - end - INPUT - assert_in_out_err([], src, %w(A.get_C), [], bug5702) - end - def test_constant_lookup_in_method_defined_by_class_eval src = <<-INPUT class A -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/