summary refs log tree commit diff stats
path: root/tests/destructor
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-05-24 00:12:36 +0200
committerAraq <rumpf_a@web.de>2019-05-24 00:12:36 +0200
commitb75ad05267bad6f10e1939354eac14ac821fb8c6 (patch)
treee001b946cffd86c12a808e1233411704aa263059 /tests/destructor
parent981f95757c4b312a4f3e4bc6d6d92b3734331e98 (diff)
downloadNim-b75ad05267bad6f10e1939354eac14ac821fb8c6.tar.gz
fixes move analyser; refs #11257
Diffstat (limited to 'tests/destructor')
-rw-r--r--tests/destructor/tconsume_twice.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/destructor/tconsume_twice.nim b/tests/destructor/tconsume_twice.nim
new file mode 100644
index 000000000..a06ea4efd
--- /dev/null
+++ b/tests/destructor/tconsume_twice.nim
@@ -0,0 +1,12 @@
+discard """
+  cmd: "nim c --newruntime $file"
+  errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(8, 6)"
+  line: 10
+"""
+
+proc consumeTwice(a: owned proc()): owned proc() =
+  if a == nil:
+    return
+  return a
+
+assert consumeTwice(proc() = discard) != nil