mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
workaround #23435 related to https://github.com/nim-lang/Nim/issues/22852 see also #23279
This commit is contained in:
@@ -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)
|
||||
|
||||
12
tests/errmsgs/t23435.nim
Normal file
12
tests/errmsgs/t23435.nim
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user