From a848954f5d2f9a0a6d91f9b6a822c38163d61ba0 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 23 Jun 2026 21:33:30 +0200 Subject: [PATCH] Fixed incorrect strings.index implementation --- lib/strings/index.q | 1 + tests/strings-index.q | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/strings/index.q b/lib/strings/index.q index c61eb43..dc8f542 100644 --- a/lib/strings/index.q +++ b/lib/strings/index.q @@ -17,6 +17,7 @@ index(a string, b string) -> (uint, error) { return i - j + 1, 0 } } else { + i -= j j = 0 } } diff --git a/tests/strings-index.q b/tests/strings-index.q index d93ac1a..4ace367 100644 --- a/tests/strings-index.q +++ b/tests/strings-index.q @@ -25,6 +25,10 @@ main() { assert err == 0 assert posLL == 2 + posHello, err := strings.index("HHeHelHellHello", "Hello") + assert err == 0 + assert posHello == 10 + _, err1 := strings.index("Hello", "Hello World") assert err1 != 0 -- 2.51.2