introduce precise string '[]', '[]=' accessors; fixes #8049 (#8817)

This commit is contained in:
Andreas Rumpf
2018-08-30 23:01:15 +02:00
committed by GitHub
parent dfdf8e58c7
commit df4d5b77a1
4 changed files with 33 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
discard """
output: '''0
0'''
0
bc
bcdefg'''
"""
# test another strange bug ... (I hate this compiler; it is much too buggy!)
@@ -29,3 +31,13 @@ var
echo obj.s1[0]
echo obj.s1[0u]
# bug #8049
when true:
type ustring* = distinct string
converter toUString*(s: string): ustring = ustring(s)
proc `[]`*(s: ustring, i: int): ustring = s
echo "abcdefgh"[1..2]
echo "abcdefgh"[1..^2]