Top level variables are moved sometimes
beef331 opened this issue · comments
Jason Beetham commented
Description
Depending on what hooks exist for a type top level variables might be moved instead of copied:
type MyType = object
a: int
proc `=destroy`(typ: MyType) = echo "Destroyed: ", typ.a
var t1 = MyType(a: 100)
var t2 = t1 # Should be a copy?
proc main() =
t2 = t1
echo t1
echo t2
main()
Nim Version
2.0.4 and devel
Current Output
(a: 0)
(a: 0)
Destroyed: 0
Destroyed: 0
Expected Output
(a: 100)
(a: 100)
Destroyed: 100
Destroyed: 100
Possible Solution
No response
Additional Information
No response