Backport #6000
respond_to? check in check_funcall() does not work with single-argument respond_to?
Description
=begin
The following code works in Ruby 1.9.3:
class C
def respond_to? name
super name
end
end
[C.new].flatten
But fails with ArgumentError after r32855:
$ ruby20 -v test.rb
ruby 2.0.0dev (2012-02-11 trunk 34547) [x86_64-darwin11.2.0]
test.rb:2:in respond_to?': wrong number of arguments (2 for 1) (ArgumentError)
flatten'
from test.rb:7:in
from test.rb:7:in `'
I think this should still work to support legacy 1.9 applications in 2.0
=end
Files
Associated revisions
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
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
merge revision(s) r34564:
* vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to? requires more than three arguments. [Bug #6000] * test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to?
requires more than three arguments. [Bug #6000]
- test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to?
requires more than three arguments. [Bug #6000]
- test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to?
requires more than three arguments. [Bug #6000]
- test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to?
requires more than three arguments. [Bug #6000]
- test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to?
requires more than three arguments. [Bug #6000]
- test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
- vm_eval.c (check_funcall): Raise ArgumentError if respond_to?
requires more than three arguments. [Bug #6000]
- test/ruby/test_object.rb (class TestObject): Test for respond_to? requiring more than three arguments.
History
Updated by drbrain (Eric Hodel) almost 8 years ago
Updated by drbrain (Eric Hodel) almost 8 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r34564.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
Updated by naruse (Yui NARUSE) almost 8 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193
- Category deleted (
core) - Status changed from Closed to Open
- Target version deleted (
2.0.0)
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
- Status changed from Open to Closed
This issue was solved with changeset r34616.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) r34564:
* vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]
Updated by mame (Yusuke Endoh) over 7 years ago
- Status changed from Closed to Assigned
- Assignee set to drbrain (Eric Hodel)
Hello,
Your patch causes SEGV:
class C
def respond_to? x, y, z
p z
end
end
[C.new].flatten #=> SEGV
Did you mean "arity >= 3" instead of "arity > 3" ?
(Note that I don't understand this ticket.)
Coverity Scan found this bug.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by usa (Usaku NAKAMURA) over 7 years ago
- Tracker changed from Backport to Bug
- Project changed from Backport193 to Ruby master
Updated by drbrain (Eric Hodel) over 7 years ago
- ruby -v set to -
=begin
Fixed by r35025
I was depending upon vm_call0() to perform arity checking, but it does not, so r35025 does it by hand.
Existing ruby libraries have (({def respond_to? method})). Before r34564 ruby trunk called respond_to? with two arguments, the method and a boolean to include private methods, which broke backwards compatibility. This bug is about allowing respond_to? implementations from ruby 1.8 and ruby 1.9 to continue to work.
=end
Updated by drbrain (Eric Hodel) over 7 years ago
- Status changed from Assigned to Closed
I do not know how to move this ticket to the Backport tracker, can someone please backport it?
Updated by marcandre (Marc-Andre Lafortune) over 7 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193
Moved as backport
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e