This piece of code yields a warning.
ruby a.rb
/home/neoneye/stow/ruby/lib/ruby/1.8/delegate.rb:110: warning: method redefined; discarding old getobj
expand -t2 a.rb
require ‘delegate’
class MockA < DelegateClass(String)
def initialize; super(‘a’) end
end
class MockB < DelegateClass(String)
def initialize; super(‘b’) end
end
I uncommented the “redefined” method and the warning went away…
I cannot tell if it has consequences for the functionality of delegate?
diff -u old.delegate.rb delegate.rb
— old.delegate.rb Tue Dec 16 08:33:25 2003
+++ delegate.rb Tue Mar 30 21:46:28 2004
@@ -107,9 +107,11 @@
raise NameError, “invalid identifier %s” % method, caller(3)
end
end
+=begin
def getobj
@_dc_obj
end
+=end
return klass;
end
ruby -v
ruby 1.8.1 (2003-12-22) [i386-freebsd5.1]
···
–
Simon Strandgaard
Hi,
At Wed, 31 Mar 2004 04:59:24 +0900,
Simon Strandgaard wrote in [ruby-talk:96156]:
ruby a.rb
/home/neoneye/stow/ruby/lib/ruby/1.8/delegate.rb:110: warning: method redefined; discarding old getobj
expand -t2 a.rb
require ‘delegate’
class MockA < DelegateClass(String)
def initialize; super(‘a’) end
end
class MockB < DelegateClass(String)
def initialize; super(‘b’) end
end
I uncommented the “redefined” method and the warning went away…
I cannot tell if it has consequences for the functionality of delegate?
I think it should be like followings.
Index: delegate.rb
···
===================================================================
RCS file: /cvs/ruby/src/ruby/lib/delegate.rb,v
retrieving revision 1.16
diff -u -2 -p -r1.16 delegate.rb
— delegate.rb 29 Mar 2004 07:54:31 -0000 1.16
+++ delegate.rb 30 Mar 2004 22:46:16 -0000
@@ -92,4 +92,10 @@ def DelegateClass(superclass)
@_dc_obj = obj
end
- def getobj
- @_dc_obj
- end
- def setobj(obj)
- @_dc_obj = obj
- end
EOS
for method in methods
@@ -109,11 +115,5 @@ def DelegateClass(superclass)
end
end
- def getobj
- @_dc_obj
- end
- def setobj(obj)
- @_dc_obj = obj
- end
- return klass;
–
Nobu Nakada
I uncommented the “redefined” method and the warning went away…
I cannot tell if it has consequences for the functionality of delegate?
I think it should be like followings.
Commit this fix, please.
matz.
Thanks Nobu+Matz for a perfectly working solution.
Now all my tests executes without outputting any warnings
ruby -w test_all.rb
Loaded suite Unnamed TestSuite
Started
… [snip] …
Finished in 8.383372 seconds.
655 tests, 804 assertions, 0 failures, 0 errors
···
On Wed, 31 Mar 2004 12:01:33 +0900, Yukihiro Matsumoto wrote:
In message “Re: patch to delegate.rb to disable warning” > on 04/03/31, nobu.nokada@softhome.net nobu.nokada@softhome.net writes:
–
Simon Strandgaard