diff options
Diffstat (limited to 'tests/views/tdont_mutate.nim')
-rw-r--r-- | tests/views/tdont_mutate.nim | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/views/tdont_mutate.nim b/tests/views/tdont_mutate.nim index d243c7c7a..eb5a82cbf 100644 --- a/tests/views/tdont_mutate.nim +++ b/tests/views/tdont_mutate.nim @@ -9,8 +9,9 @@ import tables const Whitespace = {' ', '\t', '\n', '\r'} -proc split*(s: string, seps: set[char] = Whitespace, - maxsplit: int = -1): Table[int, openArray[char]] = +proc split*(s: string, seps: set[char] = Whitespace, maxsplit: int = -1): Table[int, openArray[char]] #[tt.Error +^ 'result' borrows from the immutable location 's' and attempts to mutate it + ]# = var last = 0 var splits = maxsplit result = initTable[int, openArray[char]]() @@ -22,9 +23,7 @@ proc split*(s: string, seps: set[char] = Whitespace, if splits == 0: last = len(s) result[first] = toOpenArray(s, first, last-1) - result[first][0] = 'c' #[tt.Error - attempt to mutate a borrowed location from an immutable view - ]# + result[first][0] = 'c' if splits == 0: break dec(splits) @@ -36,7 +35,7 @@ proc `$`(x: openArray[char]): string = proc otherTest(x: int) = var y: var int = x #[tt.Error - 'y' borrows from the immutable location 'x' and attempts to mutate it + ^ 'y' borrows from the immutable location 'x' and attempts to mutate it ]# y = 3 |