tsinkbug.nim 409 B

123456789101112131415161718192021222324252627
  1. discard """
  2. matrix: "--mm:refc; --mm:arc"
  3. output: '''
  4. Value is: 42
  5. Value is: 42'''
  6. """
  7. type AnObject* = object of RootObj
  8. value*: int
  9. proc mutate(a: sink AnObject) =
  10. a.value = 1
  11. var obj = AnObject(value: 42)
  12. echo "Value is: ", obj.value
  13. mutate(obj)
  14. echo "Value is: ", obj.value
  15. proc p(x: sink string) =
  16. var y = move(x)
  17. doAssert x.len == 0
  18. doAssert y.len == 4
  19. p("1234")
  20. var s = "oooo"
  21. p(s)