https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112013-01-09T23:00:05ZRuby Issue Tracking SystemRuby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353042013-01-09T23:00:05ZAnonymous
<ul><li><strong>File</strong> <a href="/attachments/3420">bug-7676.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/3420/bug-7676.patch">bug-7676.patch</a> added</li></ul><p>Attached a patch fixing this issue - the pointer equality checks in <code>recursive_equal</code> and <code>rb_equal</code> should not be performed as this breaks in the case where <code>a != a</code>.</p>
<p>I'm not committing this straight away because it causes three test failures due to brittle mocks.</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353052013-01-09T23:41:33Zngoto (Naohisa Goto)ngotogenome@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>duplicate of Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: [NaN] == [NaN] が true になる (Closed)" href="https://redmine.ruby-lang.org/issues/1720">#1720</a></p>
<p>See documentation in numeric.c added in r37546<br>
<a href="https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/37546/diff/numeric.c" class="external">https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/37546/diff/numeric.c</a></p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353062013-01-10T09:20:06Zsimonrussell (Simon Russell)spam+ruby@bellyphant.com
<ul></ul><p>This isn't just <code>Float::NAN</code>, actually; as Charlie's patch shows, it's actually any object that always returns false from <code>==</code></p>
<pre><code>1.9.3p125 :001 > class X
1.9.3p125 :002?> def ==(other)
1.9.3p125 :003?> false
1.9.3p125 :004?> end
1.9.3p125 :005?> end
=> nil
1.9.3p125 :006 > x = X.new
=> #<X:0x00000000ba1648>
1.9.3p125 :007 > x == x
=> false
1.9.3p125 :008 > [x] == [x]
=> true
</code></pre>
<p>Is this desirable behaviour?</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353072013-01-10T09:23:58Zsimonrussell (Simon Russell)spam+ruby@bellyphant.com
<ul></ul><p>At the very least, the documentation for Array#== should be updated to state that it first does an object identity comparison, then calls == only if the objects aren't the same instance.</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353092013-01-10T11:18:45Zhasari (Hiro Asari)asari.ruby@gmail.com
<ul></ul><p>I, too, found documentation still lacking. I read <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: [NaN] == [NaN] が true になる (Closed)" href="https://redmine.ruby-lang.org/issues/1720">#1720</a>, and I understand the rationale for the Float::NAN case.</p>
<p>However, the issue still remains as Simon pointed out above. Please reopen the issue, or update the documentation to reflect the behavior more closely.</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353102013-01-10T11:28:04Zngoto (Naohisa Goto)ngotogenome@gmail.com
<ul><li><strong>Category</strong> set to <i>doc</i></li><li><strong>Status</strong> changed from <i>Rejected</i> to <i>Open</i></li></ul> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353112013-01-10T11:30:47Zmrkn (Kenta Murata)muraken@gmail.com
<ul><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li><li><strong>Target version</strong> set to <i>2.6</i></li></ul><p>I think this is the specification issue, so we need to confirm the mat'z thought.<br>
Matz, how do you think about it?</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=353122013-01-10T11:38:44ZAnonymous
<ul></ul><p>I understand that matz wants <code>nan == nan</code> to be undefined, but I think this should remain consistent within a platform, even though it is undefined between platforms.</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=409062013-08-06T00:51:00Zsteveklabnik (Steve Klabnik)steve@steveklabnik.com
<ul></ul><p>I would be happy to write a documentation patch for this if Matz can confirm which behavior is correct.</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=561202016-01-16T11:28:13Zdwfait (Dwain Faithfull)dwfaithfull@gmail.com
<ul></ul><p>It appears calling eql? on array does not behave in this way:</p>
<pre><code>[Float::NAN].eql? [Float::NAN]
=> false
</code></pre>
<p>Should we aim for consistency between these methods? Does it make sense for one to have an identity check and for the other not to?</p>
<p>I believe it doesn't really make sense for == to have an identity check, as the example in #3 is not how I'd expect Ruby to behave.</p> Ruby master - Bug #7676: Comparison of Float::NAN in array behaves unexpectedlyhttps://redmine.ruby-lang.org/issues/7676?journal_id=936292021-09-13T16:09:39Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>