class.c: check redefinition

* class.c (rb_prepend_module): check redefinition of built-in opimized
  methods.  [ruby-dev:47124] [Bug #7983]
* vm.c (rb_vm_check_redefinition_by_prepend): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-03-05 12:36:45 +00:00
parent 00a8203b0b
commit f113ab552c
4 changed files with 62 additions and 11 deletions

View file

@ -1475,6 +1475,20 @@ class TestModule < Test::Unit::TestCase
end
end
def test_prepend_optmethod
bug7983 = '[ruby-dev:47124] [Bug #7983]'
assert_separately [], %{
module M
def /(other)
to_f / other
end
end
Fixnum.send(:prepend, M)
assert_equal(0.5, 1 / 2, "#{bug7983}")
}
assert_equal(0, 1 / 2)
end
def test_class_variables
m = Module.new
m.class_variable_set(:@@foo, 1)