Warn redefinitions of some methods on Object
[Bug #5473] [Bug #14670] [Bug #15382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
973f84ef55
commit
76e3af82d5
@ -1344,6 +1344,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||||||
def test_super_in_method_missing
|
def test_super_in_method_missing
|
||||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
begin;
|
begin;
|
||||||
|
$VERBOSE = nil
|
||||||
class Object
|
class Object
|
||||||
def method_missing(name, *args, &block)
|
def method_missing(name, *args, &block)
|
||||||
super
|
super
|
||||||
|
@ -188,7 +188,7 @@ class TestInteger < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
begin;
|
begin;
|
||||||
def method_missing(*);"";end
|
class Integer;def method_missing(*);"";end;end
|
||||||
assert_equal(0, Integer("0", 2))
|
assert_equal(0, Integer("0", 2))
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
@ -883,6 +883,7 @@ class TestObject < Test::Unit::TestCase
|
|||||||
['ArgumentError.new("bug5473")', 'ArgumentError, "bug5473"', '"bug5473"'].each do |code|
|
['ArgumentError.new("bug5473")', 'ArgumentError, "bug5473"', '"bug5473"'].each do |code|
|
||||||
exc = code[/\A[A-Z]\w+/] || 'RuntimeError'
|
exc = code[/\A[A-Z]\w+/] || 'RuntimeError'
|
||||||
assert_separately([], <<-SRC)
|
assert_separately([], <<-SRC)
|
||||||
|
$VERBOSE = nil
|
||||||
class ::Object
|
class ::Object
|
||||||
def method_missing(m, *a, &b)
|
def method_missing(m, *a, &b)
|
||||||
raise #{code}
|
raise #{code}
|
||||||
|
10
vm_method.c
10
vm_method.c
@ -605,8 +605,14 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
|
|||||||
rb_clear_method_cache_by_class(klass);
|
rb_clear_method_cache_by_class(klass);
|
||||||
|
|
||||||
/* check mid */
|
/* check mid */
|
||||||
if (klass == rb_cObject && mid == idInitialize) {
|
if (klass == rb_cObject) {
|
||||||
rb_warn("redefining Object#initialize may cause infinite loop");
|
switch (mid) {
|
||||||
|
case idInitialize:
|
||||||
|
case idRespond_to_missing:
|
||||||
|
case idMethodMissing:
|
||||||
|
case idRespond_to:
|
||||||
|
rb_warn("redefining Object#%s may cause infinite loop", rb_id2name(mid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* check mid */
|
/* check mid */
|
||||||
if (mid == object_id || mid == id__send__) {
|
if (mid == object_id || mid == id__send__) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user