fixes #15038 [backport:1.2]
This commit is contained in:
parent
624762cfb7
commit
aae998feff
3 changed files with 29 additions and 46 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue