diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-04-19 03:55:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 21:55:26 +0200 |
commit | 229c125d2f66bf983b16b7b56b6e7aeff58f7663 (patch) | |
tree | 1447c9213cf49ff937a11c5a868cedf9f534a2fc | |
parent | 2a7ddcab2dc22f6be81380a313b604806f4c428c (diff) | |
download | Nim-229c125d2f66bf983b16b7b56b6e7aeff58f7663.tar.gz |
workaround #23435; real fix pending #23279 (#23436)
workaround #23435 related to https://github.com/nim-lang/Nim/issues/22852 see also #23279
-rw-r--r-- | lib/system/indices.nim | 2 | ||||
-rw-r--r-- | tests/errmsgs/t23435.nim | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/system/indices.nim b/lib/system/indices.nim index fb6151a74..e1ac68383 100644 --- a/lib/system/indices.nim +++ b/lib/system/indices.nim @@ -80,6 +80,8 @@ proc `[]`*[T, U: Ordinal](s: string, x: HSlice[T, U]): string {.inline, systemRa ## var s = "abcdef" ## assert s[1..3] == "bcd" ## ``` + # Workaround bug #22852 + result = "" let a = s ^^ x.a let L = (s ^^ x.b) - a + 1 result = newString(L) diff --git a/tests/errmsgs/t23435.nim b/tests/errmsgs/t23435.nim new file mode 100644 index 000000000..5e2e4c82a --- /dev/null +++ b/tests/errmsgs/t23435.nim @@ -0,0 +1,12 @@ +discard """ + outputsub: "Error: unhandled exception: value out of range: -15 notin 0 .. 9223372036854775807 [RangeDefect]" + exitcode: "1" +""" + +# bug #23435 +proc foo() = + for _ in @[1, 3, 5]: + discard "abcde"[25..<10] + break + +foo() |