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

Class inheriting from function generates invalid constructor #249

Closed
hadley opened this issue Aug 8, 2022 · 1 comment · Fixed by #280
Closed

Class inheriting from function generates invalid constructor #249

hadley opened this issue Aug 8, 2022 · 1 comment · Fixed by #280

Comments

@hadley
Copy link
Member

hadley commented Aug 8, 2022

library(R7)

foo <- new_class("foo", class_function)
unclass(foo)
#> Error in print.default(x, useSource = useSource, ...): badly formed function expression

Created on 2022-08-08 by the reprex package (v2.0.1)

@hadley
Copy link
Member Author

hadley commented Feb 19, 2023

It's weird that we're re-binding function here:

library(S7)

foo <- new_class("foo", class_function)
environment(foo)$`function`
#> function(.data = class_missing) {
#>     if (is_class_missing(.data)) {
#>       .data <- base_default(name)
#>     }
#>     .data
#>   }
#> <bytecode: 0x10cad7b58>
#> <environment: 0x10828f928>

Created on 2023-02-19 with reprex v2.0.2

Oh that's because we're extending function — I wonder if that's the root of the problem.

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

Successfully merging a pull request may close this issue.

1 participant