[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>

Currently, ruby/spec is maintained mostly by individuals and enjoys the

13 messages 2016/12/13

[ruby-core:78594] [Ruby trunk Bug#13025] String equality operator does not perform implicit conversion

From: john@...
Date: 2016-12-12 06:03:02 UTC
List: ruby-core #78594
Issue #13025 has been reported by John Carney.

----------------------------------------
Bug #13025: String equality operator does not perform implicit conversion
https://bugs.ruby-lang.org/issues/13025

* Author: John Carney
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.3
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
According to the documentation, String#== should perform implicit conversion of non-strings, but this is not happening.

~~~
class SomeClass
  def initialize(value)
    @value = value
  end

  def to_str
    @value.to_s
  end
end

"text" == SomeClass.new("text")
# => false (expected true)
~~~

Other operators work as expected:

~~~
"text" + SomeClass.new("text")
# => "texttext"

"text" <=> SomeClass.new("text")
# => 0
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next