Warn when redefining __id__ as well as object_id

[Feature #20912]
This commit is contained in:
John Hawthorn 2024-11-26 16:40:47 -08:00
parent a505cd32fb
commit f1dda5ed01
Notes: git 2024-11-30 04:41:19 +00:00
5 changed files with 11 additions and 8 deletions

View file

@ -1488,7 +1488,7 @@ class TestModule < Test::Unit::TestCase
class << o; self; end.instance_eval { undef_method(:foo) }
end
%w(object_id __send__ initialize).each do |n|
%w(object_id __id__ __send__ initialize).each do |n|
assert_in_out_err([], <<-INPUT, [], %r"warning: undefining '#{n}' may cause serious problems$")
$VERBOSE = false
Class.new.instance_eval { undef_method(:#{n}) }

View file

@ -480,7 +480,7 @@ class TestObject < Test::Unit::TestCase
end
def test_redefine_method_which_may_case_serious_problem
%w(object_id __send__).each do |m|
%w(object_id __id__ __send__).each do |m|
assert_in_out_err([], <<-INPUT, [], %r"warning: redefining '#{m}' may cause serious problems$")
$VERBOSE = false
def (Object.new).#{m}; end
@ -542,7 +542,7 @@ class TestObject < Test::Unit::TestCase
bug2202 = '[ruby-core:26074]'
assert_raise(NoMethodError, bug2202) {o2.meth2}
%w(object_id __send__ initialize).each do |m|
%w(object_id __id__ __send__ initialize).each do |m|
assert_in_out_err([], <<-INPUT, %w(:ok), %r"warning: removing '#{m}' may cause serious problems$")
$VERBOSE = false
begin