Skip to content

Commit d753e0a

Browse files
Lillian Zhangeregon
authored andcommitted
handle string#scrub when replacement is frozen
(cherry picked from commit 5645635)
1 parent 2c6ddd7 commit d753e0a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/truffleruby/core/string/StringNodes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,9 +1941,9 @@ protected RubyString scrubAsciiCompat(Object string, RubyProc block,
19411941
}
19421942
}
19431943
}
1944-
RubyString repl = (RubyString) yieldNode
1944+
Object repl = yieldNode
19451945
.yield(block, makeStringNode.fromRope(substringNode.executeSubstring(rope, p, clen)));
1946-
buf = concatNode.executeConcat(buf, repl.rope, enc);
1946+
buf = concatNode.executeConcat(buf, strings.getRope(repl), enc);
19471947
p += clen;
19481948
p1 = p;
19491949
p = StringSupport.searchNonAscii(pBytes, p, e);
@@ -1957,9 +1957,9 @@ protected RubyString scrubAsciiCompat(Object string, RubyProc block,
19571957
buf = concatNode.executeConcat(buf, substringNode.executeSubstring(rope, p1, p - p1), enc);
19581958
}
19591959
if (p < e) {
1960-
RubyString repl = (RubyString) yieldNode
1960+
Object repl = yieldNode
19611961
.yield(block, makeStringNode.fromRope(substringNode.executeSubstring(rope, p, e - p)));
1962-
buf = concatNode.executeConcat(buf, repl.rope, enc);
1962+
buf = concatNode.executeConcat(buf, strings.getRope(repl), enc);
19631963
}
19641964

19651965
return makeStringNode.fromRope(buf);

0 commit comments

Comments
 (0)