t6434.nim 472 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. exitcode: 0
  3. output: ""
  4. joinable: false
  5. """
  6. type
  7. Foo* = object
  8. boo: int
  9. var sink_counter = 0
  10. var assign_counter = 0
  11. proc `=sink`(dest: var Foo, src: Foo) =
  12. sink_counter.inc
  13. proc `=`(dest: var Foo, src: Foo) =
  14. assign_counter.inc
  15. proc test(): auto =
  16. var a,b : Foo
  17. return (a, b, Foo(boo: 5))
  18. var (a, b, _) = test()
  19. doAssert assign_counter == 0
  20. doAssert sink_counter == 12 # + 3 because of the conservative tuple unpacking transformation