Open
Description
From futureverse/furrr#92 (comment):
I think this is a globals bug (but is probably hard to fix). Right here, globalsOf()
filters down to only functions before calling itself recursively on those functions. This filters out the list of functions which should be searched. Not searching the list of functions means that rbern()
is never identified as a global
[...]
@HenrikBengtsson here is a globals only reprex that shows rbern()
not being found
library(extraDistr)
library(globals)
# uses rbern() from extraDistr
inner_fun <- function() rbern(10, 0.5)
# A function that calls another which is passed to it in a list
wrapper_fun <- function(fun_list) {
fun_list$sim_fun()
}
# A list of functions
list_of_funs <- list(sim_fun = inner_fun)
expr <- quote(function(i) wrapper_fun(list_of_funs))
globalsOf(expr)
#> $wrapper_fun
#> function(fun_list) {
#> fun_list$sim_fun()
#> }
#>
#> $list_of_funs
#> $list_of_funs$sim_fun
#> function() rbern(10, 0.5)
#>
#>
#> $`{`
#> .Primitive("{")
#>
#> $`$`
#> .Primitive("$")
#>
#> attr(,"class")
#> [1] "Globals" "list"
#> attr(,"where")
#> attr(,"where")$wrapper_fun
#> <environment: R_GlobalEnv>
#>
#> attr(,"where")$list_of_funs
#> <environment: R_GlobalEnv>
#>
#> attr(,"where")$`{`
#> <environment: base>
#>
#> attr(,"where")$`$`
#> <environment: base>
Activity