Skip to content

Commit 0973f2c

Browse files
committed
Fix the return value of String#split String#split with a block on a non-ASCII String
1 parent 856bd3b commit 0973f2c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,7 @@ protected Object stringAwkSplitSingleByte(Object string, int limit, Object block
34723472

34733473
@TruffleBoundary
34743474
@Specialization(guards = "!is7Bit(strings.getRope(string), codeRangeNode)")
3475-
protected RubyArray stringAwkSplit(Object string, int limit, Object block,
3475+
protected Object stringAwkSplit(Object string, int limit, Object block,
34763476
@CachedLibrary(limit = "2") RubyStringLibrary strings,
34773477
@Cached ConditionProfile executeBlockProfile,
34783478
@Cached ConditionProfile growArrayProfile,
@@ -3534,7 +3534,11 @@ protected RubyArray stringAwkSplit(Object string, int limit, Object block,
35343534
ret = addSubstring(ret, storeIndex++, substring, block, executeBlockProfile, growArrayProfile);
35353535
}
35363536

3537-
return createArray(ret, storeIndex);
3537+
if (block == nil) {
3538+
return createArray(ret, storeIndex);
3539+
} else {
3540+
return string;
3541+
}
35383542
}
35393543

35403544
private Object[] addSubstring(Object[] store, int index, RubyString substring,

0 commit comments

Comments
 (0)