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:44:49 +0200
committerAraq <rumpf_a@web.de>2019-05-24 00:44:49 +0200
commitc7de1a252e2ec8ba9ce0e0872a626aad04bd4c68 (patch)
tree7f782e9975de086f6cfedc6b0a13e5e0dc3258ba /tests/destructor
parentb75ad05267bad6f10e1939354eac14ac821fb8c6 (diff)
downloadNim-c7de1a252e2ec8ba9ce0e0872a626aad04bd4c68.tar.gz
fixes #11257
Diffstat (limited to 'tests/destructor')
-rw-r--r--tests/destructor/tconsume_twice.nim13
-rw-r--r--tests/destructor/twidgets_unown.nim5
2 files changed, 13 insertions, 5 deletions
diff --git a/tests/destructor/tconsume_twice.nim b/tests/destructor/tconsume_twice.nim
index a06ea4efd..8687b3ce5 100644
--- a/tests/destructor/tconsume_twice.nim
+++ b/tests/destructor/tconsume_twice.nim
@@ -1,12 +1,15 @@
 discard """
   cmd: "nim c --newruntime $file"
-  errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(8, 6)"
-  line: 10
+  errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(11, 10)"
+  line: 13
 """
+type
+  Foo = ref object
 
-proc consumeTwice(a: owned proc()): owned proc() =
-  if a == nil:
+proc use(a: owned Foo): bool = discard
+proc consumeTwice(a: owned Foo): owned Foo =
+  if use(a):
     return
   return a
 
-assert consumeTwice(proc() = discard) != nil
+assert consumeTwice(Foo()) != nil
diff --git a/tests/destructor/twidgets_unown.nim b/tests/destructor/twidgets_unown.nim
index bd4cd76af..5e53a0e5b 100644
--- a/tests/destructor/twidgets_unown.nim
+++ b/tests/destructor/twidgets_unown.nim
@@ -62,6 +62,11 @@ proc main =
 
   w.draw()
 
+  # bug #11257
+  var a: owned proc()
+  if a != nil:
+    a()
+
 main()
 
 let (a, d) = allocCounters()