ruby-changes:40498
From: nobu <ko1@a...>
Date: Sun, 15 Nov 2015 18:29:00 +0900 (JST)
Subject: [ruby-changes:40498] nobu:r52579 (trunk): vm_method.c: check if frozen [Fix GH-1096]
nobu 2015-11-15 18:28:45 +0900 (Sun, 15 Nov 2015) New Revision: 52579 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52579 Log: vm_method.c: check if frozen [Fix GH-1096] * vm_method.c (set_method_visibility): should fail if the receiver is frozen. [ruby-core:71489] [Bug #11687] Modified files: trunk/ChangeLog trunk/test/ruby/test_module.rb trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 52578) +++ ChangeLog (revision 52579) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 15 18:28:43 2015 Kenichi Kamiya <kachick1@g...> + + * vm_method.c (set_method_visibility): should fail if the receiver + is frozen. [ruby-core:71489] [Bug #11687] + Sat Nov 14 22:15:07 2015 Tanaka Akira <akr@f...> * ext/socket/lib/socket.rb: Specify frozen_string_literal: true. Index: vm_method.c =================================================================== --- vm_method.c (revision 52578) +++ vm_method.c (revision 52579) @@ -1552,6 +1552,7 @@ set_method_visibility(VALUE self, int ar https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1552 { int i; + rb_check_frozen(self); if (argc == 0) { rb_warning("%"PRIsVALUE" with no argument is just ignored", QUOTE_ID(rb_frame_callee())); Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 52578) +++ test/ruby/test_module.rb (revision 52579) @@ -624,13 +624,22 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L624 end def test_freeze - m = Module.new + m = Module.new do + def self.baz; end + def bar; end + end m.freeze assert_raise(RuntimeError) do m.module_eval do def foo; end end end + assert_raise(RuntimeError) do + m.__send__ :private, :bar + end + assert_raise(RuntimeError) do + m.private_class_method :baz + end end def test_attr_obsoleted_flag -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/