fixes #15038 [backport:1.2]

This commit is contained in:
Andreas Rumpf 2020-07-25 22:29:45 +02:00
commit aae998feff
3 changed files with 29 additions and 46 deletions

View file

@ -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()