Skip to content

Commit f4a8406

Browse files
committed
Fix string bitwise op semantics.
Strings of different lengths want The Other Thing. With this, all Rakudo sanity tests pass on JVM.
1 parent 23a3a11 commit f4a8406

File tree

1 file changed

+9
-9
lines changed
  • src/vm/jvm/runtime/org/perl6/nqp/runtime

1 file changed

+9
-9
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,9 +2851,9 @@ public static String bitor_s(String a, String b) {
28512851
StringBuilder r = new StringBuilder(mlength);
28522852
int apos = 0;
28532853
int bpos = 0;
2854-
while (apos < alength || bpos < blength) {
2855-
int cpa = apos < alength ? a.codePointAt(apos) : 0;
2856-
int cpb = bpos < blength ? b.codePointAt(bpos) : 0;
2854+
while (apos < alength && bpos < blength) {
2855+
int cpa = a.codePointAt(apos);
2856+
int cpb = b.codePointAt(bpos);
28572857
r.appendCodePoint(cpa | cpb);
28582858
apos += Character.charCount(cpa);
28592859
bpos += Character.charCount(cpb);
@@ -2868,9 +2868,9 @@ public static String bitxor_s(String a, String b) {
28682868
StringBuilder r = new StringBuilder(mlength);
28692869
int apos = 0;
28702870
int bpos = 0;
2871-
while (apos < alength || bpos < blength) {
2872-
int cpa = apos < alength ? a.codePointAt(apos) : 0;
2873-
int cpb = bpos < blength ? b.codePointAt(bpos) : 0;
2871+
while (apos < alength && bpos < blength) {
2872+
int cpa = a.codePointAt(apos);
2873+
int cpb = b.codePointAt(bpos);
28742874
r.appendCodePoint(cpa ^ cpb);
28752875
apos += Character.charCount(cpa);
28762876
bpos += Character.charCount(cpb);
@@ -2885,9 +2885,9 @@ public static String bitand_s(String a, String b) {
28852885
StringBuilder r = new StringBuilder(mlength);
28862886
int apos = 0;
28872887
int bpos = 0;
2888-
while (apos < alength || bpos < blength) {
2889-
int cpa = apos < alength ? a.codePointAt(apos) : 0;
2890-
int cpb = bpos < blength ? b.codePointAt(bpos) : 0;
2888+
while (apos < alength && bpos < blength) {
2889+
int cpa = a.codePointAt(apos);
2890+
int cpb = b.codePointAt(bpos);
28912891
r.appendCodePoint(cpa & cpb);
28922892
apos += Character.charCount(cpa);
28932893
bpos += Character.charCount(cpb);

0 commit comments

Comments
 (0)