Seems to me that there is a bug in delete in strutils if the last parameter is bigger than the length of the string.
To demonstrate, this first example prints 'kev' as you would expect:
var s : string
s = "kevin"
s.delete(3, 4)
echo s
But if I change the last argument to be a value higher than the end of the string it deletes characters before the start point. This second example just prints 'ke':
var s : string
s = "kevin"
s.delete(3, 5)
echo s
I'm not sure what the "right" action would be according to the philosophy of Nim. Perhaps it should just limit the argument to the length of the string if it is too big the way Python does, or maybe raise some kind of exception to indicate that the programmer is doing something they don't actually want.
Any thoughts?
Any thoughts?
This is a bug. I'll fix it.