https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112010-04-28T01:19:37ZRuby Issue Tracking SystemRuby master - Bug #2224: lib/delegate: operator delegationhttps://bugs.ruby-lang.org/issues/2224?journal_id=105762010-04-28T01:19:37Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li><li><strong>Target version</strong> set to <i>1.9.2</i></li></ul><p>=begin<br>
Hi,</p>
<blockquote>
<p>The operators ==, =~, !~ are forwarded by Delegate. I presume the operators != and ~, new in 1.9, have simply been forgotten?</p>
</blockquote>
<p>Agreed. Yugui, do you permit to fix this?</p>
<blockquote>
<p>As for eql? and hash, this is probably intentional. I am still curious as to why, since this can yield surprising results (at least to me):</p>
</blockquote>
<p>Me too. Matz, is this really intentional?</p>
<p>I wrote a patch, but I cannot anticipate the impact.<br>
At least, make check and make test-rubyspec seem to pass.</p>
<p>diff --git a/lib/delegate.rb b/lib/delegate.rb<br>
index f366091..e35d3b2 100644<br>
--- a/lib/delegate.rb<br>
+++ b/lib/delegate.rb<br>
@@ -117,7 +117,7 @@<br>
class Delegator < BasicObject<br>
kernel = ::Kernel.dup<br>
kernel.class_eval do</p>
<ul>
<li>[:to_s,:inspect,:=~,:!~,:===,:<=>].each do |m|</li>
</ul>
<ul>
<li>
<p>[:to_s,:inspect,:=~,:!~,:===,:<=>,:eql?,:hash].each do |m|<br>
undef_method m<br>
end<br>
end<br>
@@ -168,6 +168,15 @@ class Delegator < BasicObject<br>
self.<strong>getobj</strong> == obj<br>
end</p>
</li>
<li>
<p>def !=(obj)</p>
</li>
<li>
<p>return true if !obj.equal?(self)</p>
</li>
<li>
<p>self.<strong>getobj</strong> != obj</p>
</li>
<li>
<p>end</p>
</li>
<li>
<li>
<p>def !</p>
</li>
<li>
<p>!self.<strong>getobj</strong></p>
</li>
<li>
<p>end</p>
</li>
<li>
<h1></h1>
<a name="This-method-must-be-overridden-by-subclasses-and-should-return-the-object"></a>
<h1 >This method must be overridden by subclasses and should return the object<a href="#This-method-must-be-overridden-by-subclasses-and-should-return-the-object" class="wiki-anchor">¶</a></h1>
<a name="method-calls-are-being-delegated-to"></a>
<h1 >method calls are being delegated to.<a href="#method-calls-are-being-delegated-to" class="wiki-anchor">¶</a></h1>
</li>
</ul>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p> Ruby master - Bug #2224: lib/delegate: operator delegationhttps://bugs.ruby-lang.org/issues/2224?journal_id=109922010-05-13T04:10:58Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul><li><strong>Assignee</strong> changed from <i>matz (Yukihiro Matsumoto)</i> to <i>marcandre (Marc-Andre Lafortune)</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #2224: lib/delegate: operator delegationhttps://bugs.ruby-lang.org/issues/2224?journal_id=116542010-06-13T04:27:07Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>=begin<br>
This issue was solved with changeset r28309.<br>
Marc-Andre, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<p>=end</p>