Issue #4994 has been updated by Sylvain Viart.


The Issue topic could be rewritten: "DelegateClass don't lookup toplevel method in 1.9.2"

Reading and patching the delegate.rb:http://redmine.ruby-lang.org/projects/ruby-19/repository/entry/lib/delegate.rb I've found that it's related to BasicObject's behavior. DelegateClass somewhat inherit from BasicObject, not Object.

This issue follow the same pattern as #3768.

The documentation should be updated how to fix that (toplevel method resolution).

But may be, I'm still miss something about the new Spec about DelegateClass.



----------------------------------------
Bug #4994: DelegateClass don't find extern global public method in 1.9.2
http://redmine.ruby-lang.org/issues/4994

Author: Sylvain Viart
Status: Rejected
Priority: Normal
Assignee: 
Category: lib
Target version: 1.9.2
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]


How to reproduce:
<pre>
require 'delegate'
require 'pp'

def test_that?(str)
    str.size > 0
end

class String2 < DelegateClass(String)
    def initialize(*param)
        @s = String.new(*param)
        super(@s)
    end

    def dummy
        test_that?(@s)
    end
end

s2 = String2.new("pipo")

pp s2.dummy
</pre>

The code above works under 1.9.1 and 1.8 but not under 1.9.2

* ruby1.9.1 -v => ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]
* ruby1.8 -v   => ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
* ruby -v      => ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

error message:
<pre>
!ruby draft/tdelegate.rb
draft/tdelegate.rb:15:in `dummy': undefined method `test_that?' for "pipo":String2 (NoMethodError)
        from draft/tdelegate.rb:21:in `<main>'

shell returned 1
</pre>



-- 
http://redmine.ruby-lang.org