Skip to content

Commit ade15ef

Browse files
eregonandrykonchin
authored andcommitted
Fix encoding for the source TruffleString for RegularExpressionNode
1 parent 7251471 commit ade15ef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,10 +2667,11 @@ public RubyNode visitRedoNode(Nodes.RedoNode node) {
26672667

26682668
@Override
26692669
public RubyNode visitRegularExpressionNode(Nodes.RegularExpressionNode node) {
2670-
var source = toTString(node.unescaped);
26712670
var encodingAndOptions = getRegexpEncodingAndOptions(new Nodes.RegularExpressionFlags(node.flags));
2671+
var encoding = encodingAndOptions.encoding;
2672+
var source = TruffleString.fromByteArrayUncached(node.unescaped, encoding.tencoding);
26722673
try {
2673-
final RubyRegexp regexp = RubyRegexp.create(language, source, encodingAndOptions.encoding,
2674+
final RubyRegexp regexp = RubyRegexp.create(language, source, encoding,
26742675
encodingAndOptions.options, currentNode);
26752676
final ObjectLiteralNode literalNode = new ObjectLiteralNode(regexp);
26762677
return assignPositionAndFlags(node, literalNode);

0 commit comments

Comments
 (0)