File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
src/main/java/org/truffleruby/parser Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -2400,10 +2400,20 @@ public RubyNode visitInterpolatedRegularExpressionNode(Nodes.InterpolatedRegular
2400
2400
}
2401
2401
2402
2402
for (ToSNode child : children ) {
2403
- // assume string fragments are represented with FrozenStringLiteralNode and not StringLiteralNode
2404
- if (child .getValueNode () instanceof FrozenStringLiteralNode frozenStringLiteralNode ) {
2405
- ImmutableRubyString frozenString = frozenStringLiteralNode .getFrozenString ();
2406
- var fragment = new TStringWithEncoding (frozenString .tstring , frozenString .encoding );
2403
+ // Expect that String fragments are represented either with FrozenStringLiteralNode or StringLiteralNode.
2404
+ // StringLiteralNode is possible in the following case: /a #{ "b" } c/
2405
+ if (child .getValueNode () instanceof FrozenStringLiteralNode ||
2406
+ child .getValueNode () instanceof StringLiteralNode ) {
2407
+ final TStringWithEncoding fragment ;
2408
+
2409
+ if (child .getValueNode () instanceof FrozenStringLiteralNode frozenStringLiteralNode ) {
2410
+ ImmutableRubyString frozenString = frozenStringLiteralNode .getFrozenString ();
2411
+ fragment = new TStringWithEncoding (frozenString .tstring , frozenString .encoding );
2412
+ } else if (child .getValueNode () instanceof StringLiteralNode stringLiteralNode ) {
2413
+ fragment = new TStringWithEncoding (stringLiteralNode .getTString (), stringLiteralNode .getEncoding ());
2414
+ } else {
2415
+ throw CompilerDirectives .shouldNotReachHere ();
2416
+ }
2407
2417
2408
2418
try {
2409
2419
// MRI: reg_fragment_check
You can’t perform that action at this time.
0 commit comments