tconsume_twice.nim 433 B

12345678910111213141516
  1. discard """
  2. cmd: "nim c --newruntime $file"
  3. errormsg: "'=copy' is not available for type <owned Foo>; requires a copy because it's not the last read of 'a'; another read is done here: tconsume_twice.nim(13, 10); routine: consumeTwice"
  4. line: 11
  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