make var string return var char w/ BackwardsIndex (#15461)

* make var string return var char w/ BackwardsIndex

fixes #14497

* work around VM bug
* properly workaround again
This commit is contained in:
hlaaftana 2020-11-12 13:44:21 +03:00 • committed by GitHub
commit 527e792827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -91,3 +91,10 @@ proc tester[T](x: T) =
tester(1)
# #14497
func reverse*(a: string): string =
result = a
for i in 0 ..< a.len div 2:
swap(result[i], result[^(i + 1)])
doAssert reverse("hello") == "olleh"