зеркало из https://github.com/github/ruby.git
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
9fec02ad20
Коммит
4ea616b387
|
@ -1,3 +1,8 @@
|
|||
Sun Nov 15 18:28:43 2015 Kenichi Kamiya <kachick1@gmail.com>
|
||||
|
||||
* 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@fsij.org>
|
||||
|
||||
* ext/socket/lib/socket.rb: Specify frozen_string_literal: true.
|
||||
|
|
|
@ -624,13 +624,22 @@ class TestModule < Test::Unit::TestCase
|
|||
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
|
||||
|
|
|
@ -1552,6 +1552,7 @@ set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_visibil
|
|||
{
|
||||
int i;
|
||||
|
||||
rb_check_frozen(self);
|
||||
if (argc == 0) {
|
||||
rb_warning("%"PRIsVALUE" with no argument is just ignored",
|
||||
QUOTE_ID(rb_frame_callee()));
|
||||
|
|
Загрузка…
Ссылка в новой задаче