diff options
Diffstat (limited to 'tests/refc/tsinkbug.nim')
-rw-r--r-- | tests/refc/tsinkbug.nim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/refc/tsinkbug.nim b/tests/refc/tsinkbug.nim new file mode 100644 index 000000000..de2ec98a5 --- /dev/null +++ b/tests/refc/tsinkbug.nim @@ -0,0 +1,26 @@ +discard """ + matrix: "--gc:refc; --gc:arc" + output: ''' +Value is: 42 +Value is: 42''' +""" + +type AnObject* = object of RootObj + value*: int + +proc mutate(a: sink AnObject) = + a.value = 1 + +var obj = AnObject(value: 42) +echo "Value is: ", obj.value +mutate(obj) +echo "Value is: ", obj.value + +proc p(x: sink string) = + var y = move(x) + doAssert x.len == 0 + doAssert y.len == 4 + +p("1234") +var s = "oooo" +p(s) |