Skip to content

Commit

Permalink
[Truffle] Whoops. We need to make a copy here since Strings are mutab…
Browse files Browse the repository at this point in the history
…le and changes shouldn't be shared.
  • Loading branch information
nirvdrum committed Jan 12, 2015
1 parent 4e86fcd commit 9fa7d9a
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -18,6 +18,7 @@
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyMatchData;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.util.ByteList;

@CoreClass(name = "MatchData")
public abstract class MatchDataNodes {
Expand Down Expand Up @@ -191,10 +192,11 @@ public ToSNode(ToSNode prev) {
}

@Specialization
public RubyString toA(RubyMatchData matchData) {
public RubyString toS(RubyMatchData matchData) {
notDesignedForCompilation();

return matchData.getGlobal();
final ByteList bytes = matchData.getGlobal().getBytes().dup();
return getContext().makeString(bytes);
}
}

Expand Down

0 comments on commit 9fa7d9a

Please sign in to comment.