-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
originally reported here: #17230 (comment)
=destroy
should work the same on all backends otherwise assumptions are broken when using code written for a backend on another backend, leading to not just bugs but silent bugs.
Example 1
when true:
type
A = object
id: int
B = object
a: A
proc `=destroy`(a: var A) = echo a.id
template main =
var x = A(id: 1)
var y = B(a: A(id: 2))
`=destroy`(x)
`=destroy`(y)
echo "here"
static: main()
main()
nim r main
Current Output
both with and without --gc:arc:
ct:
1
here
rt:
1
2
here
2
1
Expected Output
ct:
1
2
here
2
1
rt:
1
2
here
2
1
Example 2
ditto with with -b:js
ct:
1
here
rt:
1
2
here
expected output: same as previous Expected Output
Additional Information
1.5.1 02f4464
related
- regression(0.20) destructor not called in VM #11612
- Enable manual destructor invocation for implicitly generated destructors #5342 which was fixed (for c backend)