Project

General

Profile

Backport #6000

respond_to? check in check_funcall() does not work with single-argument respond_to?

Added by drbrain (Eric Hodel) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:42493]

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)
from test.rb:7:in
flatten'
from test.rb:7:in `'

I think this should still work to support legacy 1.9 applications in 2.0

=end


Files

vm_eval.c.respond_to_arity.patch (1.33 KB) vm_eval.c.respond_to_arity.patch drbrain (Eric Hodel), 02/11/2012 09:02 AM

Associated revisions

Revision 691a3a2b
Added by drbrain (Eric Hodel) over 7 years ago

  • 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/trunk@34564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34564
Added by drbrain (Eric Hodel) over 7 years ago

  • vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]

Revision 34564
Added by drbrain (Eric Hodel) over 7 years ago

  • vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]

Revision 34564
Added by drbrain (Eric Hodel) over 7 years ago

  • vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]

Revision 34564
Added by drbrain (Eric Hodel) over 7 years ago

  • vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]

Revision 34564
Added by drbrain (Eric Hodel) over 7 years ago

  • vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]

Revision 34564
Added by drbrain (Eric Hodel) over 7 years ago

  • vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000]

Revision e56eea5e
Added by nobu (Nobuyoshi Nakada) over 7 years ago

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

Revision 34616
Added by nobu (Nobuyoshi Nakada) over 7 years ago

merge revision(s) r34564:

* vm_eval.c (check_funcall):  Call respond_to? with matching arity for
  legacy single-argument implementations.  [ruby-trunk - Bug #6000]

Revision 724e683e
Added by drbrain (Eric Hodel) over 7 years ago

  • 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

Revision 35025
Added by drbrain (Eric Hodel) over 7 years ago

  • 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.

Revision 35025
Added by drbrain (Eric Hodel) over 7 years ago

  • 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.

Revision 35025
Added by drbrain (Eric Hodel) over 7 years ago

  • 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.

Revision 35025
Added by drbrain (Eric Hodel) over 7 years ago

  • 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.

Revision 35025
Added by drbrain (Eric Hodel) over 7 years ago

  • 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.

Revision 35025
Added by drbrain (Eric Hodel) over 7 years ago

  • 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

#3

Updated by drbrain (Eric Hodel) over 7 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]
#4

Updated by naruse (Yui NARUSE) over 7 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)
#5

Updated by nobu (Nobuyoshi Nakada) over 7 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

#7

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?

#10

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

Also available in: Atom PDF