ruby-changes:18692
From: mame <ko1@a...>
Date: Sat, 29 Jan 2011 11:04:11 +0900 (JST)
Subject: [ruby-changes:18692] Ruby:r30718 (trunk): * vm_insnhelper.c (vm_get_ev_const): no-scope reference to toplevel
mame 2011-01-29 11:01:19 +0900 (Sat, 29 Jan 2011) New Revision: 30718 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30718 Log: * vm_insnhelper.c (vm_get_ev_const): no-scope reference to toplevel private constant has been prohibited incorrectly. * test/ruby/test_module.rb (test_toplevel_private_constant): add a test for above. Modified files: trunk/ChangeLog trunk/test/ruby/test_module.rb trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 30717) +++ ChangeLog (revision 30718) @@ -1,3 +1,11 @@ +Sat Jan 29 10:53:16 2011 Yusuke Endoh <mame@t...> + + * vm_insnhelper.c (vm_get_ev_const): no-scope reference to toplevel + private constant has been prohibited incorrectly. + + * test/ruby/test_module.rb (test_toplevel_private_constant): add a + test for above. + Sat Jan 29 08:43:23 2011 Ryan Davis <ryand-ruby@z...> * lib/rubygems*: Import rubygems 1.5.0 (release candidate @ 09893d9) Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 30717) +++ vm_insnhelper.c (revision 30718) @@ -1199,10 +1199,10 @@ } if (is_defined) { - return rb_public_const_defined(klass, id); + return rb_const_defined(klass, id); } else { - return rb_public_const_get(klass, id); + return rb_const_get(klass, id); } } else { Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 30717) +++ test/ruby/test_module.rb (revision 30718) @@ -985,4 +985,19 @@ def test_constants_with_private_constant assert(!(::TestModule).constants.include?(:PrivateClass)) end + + def test_toplevel_private_constant + src = <<-INPUT + class Object + private_constant :Object + end + p Object + begin + p ::Object + rescue + p :ok + end + INPUT + assert_in_out_err([], src, %w(Object :ok), []) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/