fix(tvix/eval): off-by-one in replaceStrings

replaceStrings would previously fail to replace the last character
in a string.

Change-Id: I43a7c960945350b2e7a5b731b7fdb617723eb38f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9151
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Linus Heckemann 2023-08-24 02:14:21 +02:00
parent e9bbc5f2af
commit a3dbb60213
3 changed files with 3 additions and 2 deletions

View file

@ -723,7 +723,7 @@ mod pure_builtins {
let from = elem.0.to_str()?;
let to = elem.1.to_str()?;
if i + from.len() >= string.len() {
if i + from.len() > string.len() {
continue;
}

View file

@ -1 +1 @@
[ "fabir" "a" "1a1" ]
[ "fabir" "a" "1a1" "ABC" ]

View file

@ -2,4 +2,5 @@
(builtins.replaceStrings ["oo" "a"] ["a" "i"] "foobar")
(builtins.replaceStrings ["o"] ["a"] "a")
(builtins.replaceStrings ["" ""] ["1" "2"] "a")
(builtins.replaceStrings ["a" "b" "c"] ["A" "B" "C"] "abc")
]