[MacRuby] #571: #respond_to? should return false for unimplemented methods
#571: #respond_to? should return false for unimplemented methods ---------------------------------+------------------------------------------ Reporter: honglilai@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ MRI >= 1.9.2's #respond_to? method now returns false for unimplemented methods. By "unimplemented" I mean methods which are #defined as rb_f_notimplement in the MRI 1.9 source code. rb_f_notimplemented is a method which raises NotImplementedErrror. An example of this is Process.fork, implemented on MRI 1.9 as rb_f_fork. The #fork method is defined on all platforms, even on platforms where fork is not actually supported (i.e. rb_f_fork is #defined to rb_f_notimplemented). However Process.respond_to?(:fork) now returns false instead of true on these platforms. MacRuby should follow this behavior. -- Ticket URL: <http://www.macruby.org/trac/ticket/571> MacRuby <http://macruby.org/>
#571: #respond_to? should return false for unimplemented methods ---------------------------------+------------------------------------------ Reporter: honglilai@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by lsansonetti@…): Let's follow MRI here and register a common implementation symbol for unimplemented methods, then refresh the UNAVAILABLE_IMP macro to also check for this symbol. -- Ticket URL: <http://www.macruby.org/trac/ticket/571#comment:1> MacRuby <http://macruby.org/>
#571: #respond_to? should return false for unimplemented methods ---------------------------------+------------------------------------------ Reporter: honglilai@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by maxime.curioni@…): Replying to [comment:1 lsansonetti@…]:
Let's follow MRI here and register a common implementation symbol for unimplemented methods, then refresh the UNAVAILABLE_IMP macro to also check for this symbol.
I followed Laurent's recommendation and added the test (whether the current method is equal to rb_f_notimplement) to the UNAVAILABLE_IMP macro. To test it, I updated spec/frozen/core/process/fork_spec.rb, to skip the old spec. I am new to MacRuby so I don't know if changing specs in the frozen directory or specifying specs just for our implementation is the way to go. Please share any criticism/comment you may about my patch. -- Ticket URL: <http://www.macruby.org/trac/ticket/571#comment:2> MacRuby <http://macruby.org/>
#571: #respond_to? should return false for unimplemented methods ---------------------------------+------------------------------------------ Reporter: honglilai@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.6 Component: MacRuby | Resolution: fixed Keywords: | ---------------------------------+------------------------------------------ Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.6 Comment: It looks like it was a bad idea to check in UNAVAILABLE_IMP since this macro is used in a few other places, and calling #fork was then triggering method_missing. I added the check in the respond_to? code path in r3397 and merged your spec change in r3398. Everything seems to work :-) -- Ticket URL: <http://www.macruby.org/trac/ticket/571#comment:3> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby