-
Notifications
You must be signed in to change notification settings - Fork 56
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
Finalize method for cloned objects is executed in the wrong environment #167
Comments
It looks like # Start off by removing everything
rm(list = ls(all.names = TRUE))
gc()
happy <- R6::R6Class(
public = list(
foo = NULL,
initialize = function() {self$foo <- ":("},
happyify = function() {self$foo <- ":)"},
finalize = function() {cat("foo: ", self$foo, "\n")}
)
)
x <- happy$new()
y <- x$clone()
y$happyify()
rm(y)
gc()
rm(x)
gc()
#> foo: :( The reason that Lines 151 to 168 in 748bb60
|
Fixed by #180. |
When cloning an R6 object, it seems the finalize method still refers to the wrong Object. The code below should illustrate the problem quite well:
This could be related to #155 but I tried it with the newest dev version from github, and the problem still persisted :(
workarounds would also be welcome.
The text was updated successfully, but these errors were encountered: