-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finalizer not called for type ref object of RootObj
when using ARC/ORC + Forward declaration
#19402
Comments
This impact NimQml. See |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Workaround: use codeReordering {.experimental: "codeReordering".}
type Foo = ref object of RootObj
proc delete(self: Foo) # it can be omitted
proc newFoo: Foo = new(result, delete)
proc delete(self: Foo) = echo("delete Foo")
if isMainModule:
proc test() = discard newFoo()
test() |
@xflywind it seems code reordering is not enough for making NimQml work..probably code reordering is experiemental for a reason :D |
Yeah, I agree. It needs a real fix. |
Look at |
@ringabout i'll try your fix asap |
@ringabout i've tested it and it works! nice!!! |
@ringabout the only thing i've notice is that even if i'm using orc/arc deletion of object is not called immediately. However if i make a call to GC.forceFullCollect i see the finalizers being called...seems like something is "deferring" the deletion |
…n and finalizer for ORC (nim-lang#20295) * fixes nim-lang#19401; fixes nim-lang#19402; rework Forward declaration and finalizer for ORC * add more tests * give it a name * make more tests * fixes tests * hidden addr for cpp * move code to a function
Example
compile with --gc:arc
Current Output
Expected Output
Additional Information
Tested nim version 1.4.2 up to devel (15e3813)
It works with --gc:refc, it gives a different problem if
type Foo = ref object
(see #19401)The text was updated successfully, but these errors were encountered: