Closed
Description
Compile with --gc:arc.
Example
type Variable = ref object
value: int
proc `=destroy`(self: var type(Variable()[])) =
echo "destroying variable"
proc newVariable(value: int): Variable =
result = Variable()
result.value = value
proc test(count: int) =
var v {.global.} = newVariable(10)
var count = count - 1
if count == 0: return
test(count)
echo "destroyed: ", v.isNil
test(3)
Current Output
destroying variable
destroyed: true
destroyed: true
Expected Output
destroyed: false
destroyed: false
Additional Information
- It was working without --gc:arc
$ nim -v
Nim Compiler Version 1.1.1 [Windows: amd64]
Compiled at 2020-03-19
Copyright (c) 2006-2019 by Andreas Rumpf
Metadata
Metadata
Assignees
Labels
No labels