summary refs log tree commit diff stats
path: root/tests/destructor/tconsume_twice.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/destructor/tconsume_twice.nim')
-rw-r--r--tests/destructor/tconsume_twice.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/destructor/tconsume_twice.nim b/tests/destructor/tconsume_twice.nim
new file mode 100644
index 000000000..b0a039e9b
--- /dev/null
+++ b/tests/destructor/tconsume_twice.nim
@@ -0,0 +1,15 @@
+discard """
+  cmd: "nim c --newruntime $file"
+  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"
+  line: 11
+"""
+type
+  Foo = ref object
+
+proc use(a: owned Foo): bool = discard
+proc consumeTwice(a: owned Foo): owned Foo =
+  if use(a):
+    return
+  return a
+
+assert consumeTwice(Foo()) != nil