tconsume_twice.nim 323 B

12345678910111213141516
  1. discard """
  2. cmd: "nim c --newruntime $file"
  3. errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(11, 10)"
  4. line: 13
  5. """
  6. type
  7. Foo = ref object
  8. proc use(a: owned Foo): bool = discard
  9. proc consumeTwice(a: owned Foo): owned Foo =
  10. if use(a):
  11. return
  12. return a
  13. assert consumeTwice(Foo()) != nil