summary refs log tree commit diff stats
path: root/tests/arc/tarcmisc.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-07-25 22:29:45 +0200
committerAndreas Rumpf <rumpf_a@web.de>2020-07-26 01:16:06 +0200
commitaae998feff6d0234ee02311d59b299adfee0b01c (patch)
treeeed92ec7b3616a022394b65326e2c54ccdfafe34 /tests/arc/tarcmisc.nim
parent624762cfb7ab17606616f75ca280b83c55c3ec3b (diff)
downloadNim-aae998feff6d0234ee02311d59b299adfee0b01c.tar.gz
fixes #15038 [backport:1.2]
Diffstat (limited to 'tests/arc/tarcmisc.nim')
-rw-r--r--tests/arc/tarcmisc.nim26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim
index d60e932a8..a7f2dd98b 100644
--- a/tests/arc/tarcmisc.nim
+++ b/tests/arc/tarcmisc.nim
@@ -25,6 +25,7 @@ new line before - @['a']
 new line after - @['a']
 finalizer
 aaaaa
+hello
 closed
 destroying variable: 20
 destroying variable: 10
@@ -293,3 +294,28 @@ proc mutstrings =
   echo data
 
 mutstrings()
+
+# bug #15038
+
+type
+  Machine = ref object
+    hello: string
+
+var machineTypes: seq[tuple[factory: proc(): Machine]]
+
+proc registerMachine(factory: proc(): Machine) =
+  var mCreator = proc(): Machine =
+    result = factory()
+
+  machineTypes.add((factory: mCreator))
+
+proc facproc(): Machine =
+  result = Machine(hello: "hello")
+
+registerMachine(facproc)
+
+proc createMachine =
+  for machine in machineTypes:
+    echo machine.factory().hello
+
+createMachine()