Skip to content

Commit

Permalink
[Truffle] - String#downcase! returning nil if no changes were made.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Dec 22, 2014
1 parent 2851935 commit 827f20a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
Expand Up @@ -457,11 +457,18 @@ public DowncaseBangNode(DowncaseBangNode prev) {
}

@Specialization
public RubyString downcase(RubyString string) {
public RubyBasicObject downcase(RubyString string) {
notDesignedForCompilation();

string.set(ByteList.create(string.toString().toLowerCase()));
return string;
ByteList newByteList = ByteList.create(string.toString().toLowerCase());
newByteList.setEncoding(string.getBytes().getEncoding());

if (newByteList.equals(string.getBytes())) {
return getContext().getCoreLibrary().getNilObject();
} else {
string.set(newByteList);
return string;
}
}
}

Expand Down

0 comments on commit 827f20a

Please sign in to comment.