Project

General

Profile

This project is closed and read-only.

Actions

Backport #6000

closed

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

Backport #6000: respond_to? check in check_funcall() does not work with single-argument respond_to?

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

Status:
Closed
[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

Updated by drbrain (Eric Hodel) over 14 years ago Actions #3

  • 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) over 14 years ago Actions #4

  • Tracker changed from Bug to Backport
  • Project changed from Ruby to 13
  • Category deleted (core)
  • Status changed from Closed to Open
  • Target version deleted (2.0.0)

Updated by nobu (Nobuyoshi Nakada) over 14 years ago Actions #5

  • 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 14 years ago Actions #6 [ruby-core:43275]

  • 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

Updated by usa (Usaku NAKAMURA) over 14 years ago Actions #7

  • Tracker changed from Backport to Bug
  • Project changed from 13 to Ruby

Updated by drbrain (Eric Hodel) over 14 years ago Actions #8 [ruby-core:43286]

  • 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 14 years ago Actions #9 [ruby-core:43287]

  • 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 14 years ago Actions #10

  • Tracker changed from Bug to Backport
  • Project changed from Ruby to 13

Moved as backport

Actions

Also available in: PDF Atom