futureverse / futureverse/globals

False positive "failed to locate global object" when using NSE

Open
#65 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
29
Forks
3
PR merge metrics
No merged PRs in 30d

Description

In the below example, I would not have expected any failures

```r
library(globals)

fn <- function(expr) {
expr <- substitute(expr)
eval(expr, envir = mtcars)
}

fn(cyl)
#> [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4

expr <- quote(fn(cyl))

globalsOf(expr)
#> Error in globalsByName(names, envir = envir, mustExist = mustExist): Identified global objects via static code inspection (fn(cyl)). Failed to locate global object in the relevant environments: 'cyl'
```

This is tough because you probably search for `cyl` in the function environment or the global environment, but it is actually evaluated in the context of `mtcars` through the `eval()`

This came up on SO as a furrr issue related to dplyr and rlang
https://stackoverflow.com/questions/64006043/using-tidy-evaluations-with-furrr

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.