Skip to content
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

[bug] active binding detaches on clone #108

Closed
epicfarmer opened this issue Dec 13, 2016 · 2 comments
Closed

[bug] active binding detaches on clone #108

epicfarmer opened this issue Dec 13, 2016 · 2 comments

Comments

@epicfarmer
Copy link

In the following code, what should be an active binding is treated as a function. Follow up to #107 . In the last line, I expect test_4$foo to return a value, but instead it returns the function code.

class_1= R6::R6Class(
    private = list(
        bar = 1
    ),
    active = list(
        foo = function(value){
            if(missing(value)){
                return(private$bar)
            }
            private$bar = value
        }
    )
)

class_2= R6::R6Class(inherit = class_1,
    active = list(
        foo = function(value){
            private$bar = private$bar/2
            if(missing(value)) {return(super$foo)}
            super$foo <- value
        }
    )
)

test_1 <- class_1$new()
test_1$foo <- 3
test_1$foo
test_2 <- class_2$new()
test_2$foo <- 3
test_2$foo
test_3 = test_1$clone(TRUE)
test_3$foo
test_4 = test_2$clone(TRUE)
test_4$foo
@wch
Copy link
Member

wch commented Dec 13, 2016

It looks like when the test_2 object is cloned, the clone's super object's active binding is not being made active.

@epicfarmer
Copy link
Author

that seems correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants