You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(factory)
# Define the function the normal way.
get_x <- function() {
get("x", .GlobalEnv)
}
get_x
## function() {
## get("x", .GlobalEnv)
## }
# Note that it shows ".GlobalEnv". It works even if I kill the srcref.
attr(get_x, "srcref") <- NULL
get_x
## function ()
## {
## get("x", .GlobalEnv)
## }
# Building from a factory shows <environment> instead of .GlobalEnv
get_from_env <- build_factory(function() get(.x, .env), .x, .env)
get_x <- get_from_env("x", .GlobalEnv)
get_x
## function ()
## get("x", <environment>)
Perhaps something to look at either in the way the factory is evaluating its inputs, or maybe in rlang itself.
The text was updated successfully, but these errors were encountered:
An interesting tip: This works, and displays as the original:
get_x<- get_from_env("x", quote(.GlobalEnv))
This bug has something to do with the arguments being evaluated as the function is created. It's related to another thing I was seeing with the .internal_variables code I added recently.
For now I'm gonna tag this with won't fix, unless something related comes up (such as maybe #28).
Perhaps something to look at either in the way the factory is evaluating its inputs, or maybe in rlang itself.
The text was updated successfully, but these errors were encountered: