diff options
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/system.nim b/lib/system.nim index 387973f4b..b9f01c306 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3529,7 +3529,10 @@ when hasAlloc or defined(nimscript): ## .. code-block:: nim ## var s = "abcdef" ## assert s[1..3] == "bcd" - result = s.substr(s ^^ x.a, s ^^ x.b) + let a = s ^^ x.a + let L = (s ^^ x.b) - a + 1 + result = newString(L) + for i in 0 ..< L: result[i] = s[i + a] proc `[]=`*[T, U](s: var string, x: HSlice[T, U], b: string) = ## slice assignment for strings. If |