summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-15 01:33:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-15 01:33:56 +0000
commite56eea5e37a43879465d2d1d99e0e0dc89ae8684 (patch)
tree5c266542d1a0b5c73b505e8a29b5da4d485be89a
parentafcd5562ae7a61479b128845360151adc3c5397c (diff)
merge revision(s) r34564:
* vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_object.rb14
-rw-r--r--version.h2
-rw-r--r--vm_eval.c5
4 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 98ddd6b2d7..8ce16be040 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 15 10:33:41 2012 Eric Hodel <drbrain@segment7.net>
+
+ * vm_eval.c (check_funcall): Call respond_to? with matching arity for
+ legacy single-argument implementations. [ruby-trunk - Bug #6000]
+
Wed Feb 15 10:25:22 2012 Naohisa Goto <ngotogenome@gmail.com>
* vm_eval.c (check_funcall): set array elements one-by-one to fix
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index d33b9f6341..3705df21c1 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -420,6 +420,20 @@ class TestObject < Test::Unit::TestCase
assert_equal([[:respond_to?, :to_ary, true]], called, bug5158)
end
+ def test_implicit_respond_to_arity_1
+ p = Object.new
+
+ called = []
+ p.singleton_class.class_eval do
+ define_method(:respond_to?) do |a|
+ called << [:respond_to?, a]
+ false
+ end
+ end
+ [[p]].flatten
+ assert_equal([[:respond_to?, :to_ary]], called, '[bug:6000]')
+ end
+
def test_method_missing_passed_block
bug5731 = '[ruby-dev:44961]'
diff --git a/version.h b/version.h
index 619c81b690..4d911cd96c 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 118
+#define RUBY_PATCHLEVEL 119
#define RUBY_RELEASE_DATE "2012-02-15"
#define RUBY_RELEASE_YEAR 2012
diff --git a/vm_eval.c b/vm_eval.c
index cfa75a46b3..6f2da3ef6f 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -274,10 +274,13 @@ check_funcall(VALUE recv, ID mid, int argc, VALUE *argv)
me = rb_method_entry(klass, idRespond_to);
if (me && !(me->flag & NOEX_BASIC)) {
VALUE args[2];
+ int arity = rb_method_entry_arity(me);
+
+ if (arity < 1 || arity > 3) arity = 2;
args[0] = ID2SYM(mid);
args[1] = Qtrue;
- if (!RTEST(vm_call0(th, recv, idRespond_to, 2, args, me))) {
+ if (!RTEST(vm_call0(th, recv, idRespond_to, arity, args, me))) {
return Qundef;
}
}