Skip to content

Commit 9fa7d9a

Browse files
committed
[Truffle] Whoops. We need to make a copy here since Strings are mutable and changes shouldn't be shared.
1 parent 4e86fcd commit 9fa7d9a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/main/java/org/jruby/truffle/nodes/core/MatchDataNodes.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.jruby.truffle.runtime.core.RubyArray;
1919
import org.jruby.truffle.runtime.core.RubyMatchData;
2020
import org.jruby.truffle.runtime.core.RubyString;
21+
import org.jruby.util.ByteList;
2122

2223
@CoreClass(name = "MatchData")
2324
public abstract class MatchDataNodes {
@@ -191,10 +192,11 @@ public ToSNode(ToSNode prev) {
191192
}
192193

193194
@Specialization
194-
public RubyString toA(RubyMatchData matchData) {
195+
public RubyString toS(RubyMatchData matchData) {
195196
notDesignedForCompilation();
196197

197-
return matchData.getGlobal();
198+
final ByteList bytes = matchData.getGlobal().getBytes().dup();
199+
return getContext().makeString(bytes);
198200
}
199201
}
200202

0 commit comments

Comments
 (0)