Skip to content
Permalink
Browse files
[Truffle] Fix String#==.
* A String never == a Symbol.
* But actual behavior is slightly more complex than that (to_str).
  • Loading branch information
eregon committed Nov 3, 2014
1 parent 2737804 commit f2b04943e7aea7383d3299f9363f76dfa08cbfb4
Showing 1 changed file with 6 additions and 8 deletions.
@@ -86,21 +86,19 @@ public EqualNode(EqualNode prev) {
super(prev);
}

@Specialization
public boolean equal(@SuppressWarnings("unused") RubyString a, @SuppressWarnings("unused") RubyNilClass b) {
return false;
}

@CompilerDirectives.SlowPath
@Specialization
public boolean equal(RubyString a, RubyString b) {
return a.equals(b.toString());
}

@CompilerDirectives.SlowPath
@Specialization
public boolean equal(RubyString a, RubySymbol b) {
return equal(a, b.toRubyString());
public boolean equal(RubyString a, Object b) {
if (b instanceof RubyString) {
return equal(a, (RubyString) b);
} else {
return false;
}
}
}

0 comments on commit f2b0494

Please sign in to comment.