-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
Description
type X = object
v: int
type Y = object
x: X
y: X
proc `=destroy`(x: var X) =
echo "Destroying X"
proc f() =
var y: Y = Y()
echo y
proc g() =
var y: Y
echo y
echo "calling f"
f()
echo "calling g"
g()
calling f
(x: (v: 0), y: (v: 0))
Destroying X
Destroying X
calling g
(x: (v: 0), y: (v: 0))
In f
, we initialize y to its defaults and destructors get called - in g
we do the same but implicitly and the destructors are not called - I would expect the behavior to be the same in both cases so as to maintain semantic equivalence for both forms of default-init.
Nim Version
https://play.nim-lang.org/#ix=4kHG - latest on play
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response