Skip to content

Commit

Permalink
fix: Fix String.ReplaceAll (#1705)
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake committed Mar 5, 2023
1 parent 67bee5c commit d3af004
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/test/stdlib/string.test.gr
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ assert String.replaceAll("/", "\/", "/test/test/test/") ==
"\/test\/test\/test\/"
assert String.replaceAll(",", "|", "test,test,test") == "test|test|test"

assert String.replaceAll("MeowMeow", "Meow", "MeowMeowMeowMeow") == "MeowMeow"
let processBytes = b => {
let ret = Array.make(Bytes.length(b), 0us)
for (let mut i = 0; i < Bytes.length(b); i += 1) {
Expand Down
2 changes: 2 additions & 0 deletions stdlib/string.gr
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ provide let replaceAll =
found = true
foundCount += 1n
foundIndexes = [tagSimpleNumber(foundIndex), ...foundIndexes]
foundIndex -= patternLen - 1n
i -= patternLen - 1n
}
}
if (found) {
Expand Down

0 comments on commit d3af004

Please sign in to comment.