Skip to content

Commit

Permalink
workaround #23435; real fix pending #23279
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Mar 25, 2024
1 parent 33902d9 commit 8ccaae7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/system/indices.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions tests/errmsgs/t23435.nim
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 8ccaae7

Please sign in to comment.